javascript - Regex for validation numbers with commas and space -
i not sure why regex expression not working. want validate if input in format :
- 12345678,12345678,12345678
- *space*12345678 , 12345678 , 12345678 , 12345678
- 12345678,12345678, space
- working: 12345678 , 12345678
- not working: 12345678 , 12345678 ,12345678
var validate_numbers = /^\s*\d{8}\s*\+*(,\s*\d{8},*)?$/;
thank you
you need describe want match in more detail. i'm going assume want match 8-digit nums delimited commas , pluses, possibly followed commas.
the problem you're taking @ 2 sets of digits. visualization.
given assumption above, regex want:
^(\s*\d{8}\s*[+,]?\s*)*$
again, can visualize on debuggex.
Comments
Post a Comment