User is going to input in the form and only allowed numbers separated by comma.
I want to allow space after comma but not before comma and white space anywhere else is fine. (I only want to add numbers not alphabets).
I want to use this in Angular Validator pattern like Validator, pattern ("[0-9,\s]+\s*$"
)
Correct: 1123, 1232312, 12323213, 13123213213
Wrong: 123 ,1232123 ,1221323123 , 12312313
I used this "[0-9,\s]+\s*$"
but it's not allowing any space.
Your regex should be:
With
^
- Starts with.(?:[0-9]+,\s)
- A non-capturing group that contains at least one numeric character, followed by a comma (,
) and whitespace (\s
).+
- At least one occurence for previous group.*
if want to match a group of numeric characters only for example: "1234".(?:[0-9]+)
- A non-capturing group that contains at least one numeric character.$
- Ends with.Demo @ regex101