I have a text box and I need to validate the date that is being input. I’d like the users to only input numbers and if they input multiple numbers separated by a comma I need them to always add a space after the comma. I want to only accept data that looks like this: 1234, 15482, 086392 or 16843
I don’t want to accept data if it looks anything like this: 13738,74848, abc , 6a738
I’m using a google form here so I need a Regex that matches the above criteria.
I have two Regex ,[^ ] and [A-Za-z] but I can’t figure out how to connect them.
>Solution :
You could write the pattern as:
^\d+(?:, \d+)*$
Explanation
^Start of string\d+Match 1+ digits(?:, \d+)*Optionally repeat matching a comma and a space followed by 1+ digits$End of string