The regular expression for numbers separated by either spaces or commas is:
\d+(?:[ ,]+\d+)*
Explanation:
- \d+
matches one or more digits
- (?:[ ,]+\d+)*
matches zero or more occurrences of:
- [ ,]+
which matches one or more spaces or commas
- \d+
which matches one or more digits
This regular expression will match a string containing one or more numbers separated by spaces or commas. For example, it will match "1, 2, 3", "4 5, 6", "7", "8,9,10".
Please start posting anonymously - your entry will be published after you log in or create a new account. This space is reserved only for answers. If you would like to engage in a discussion, please instead post a comment under the question or an answer that you would like to discuss
Asked: 2023-07-20 07:35:45 +0000
Seen: 12 times
Last updated: Jul 20 '23
What is the regular expression to eliminate the characters \n and \t?
How can the issue of text size error be resolved in an After Effect expression?
What does the expression [rep(token, nrow(.)), ] signify in R?
How can I retrieve the headings for a table in IMPORTXML on Google Sheets?
What is the regular expression that will only allow decimal input?