Ask Your Question
0

What is the regular expression for numbers separated by either spaces or commas?

asked 2023-07-20 07:35:45 +0000

plato gravatar image

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
2

answered 2023-07-20 07:42:02 +0000

pufferfish gravatar image

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".

edit flag offensive delete link more

Your Answer

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

Add Answer


Question Tools

Stats

Asked: 2023-07-20 07:35:45 +0000

Seen: 12 times

Last updated: Jul 20 '23