javascript - Regex for validation numbers with commas and space -


i not sure why regex expression not working. want validate if input in format :

  1. 12345678,12345678,12345678
  2. *space*12345678 , 12345678 , 12345678 , 12345678
  3. 12345678,12345678, space
must 8 digit if not return false. below regex expression did, working 2 sets of numbers when input set of numbers validation not working.

  1. working: 12345678 , 12345678
  2. 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

Popular posts from this blog

monitor web browser programmatically in Android? -

Shrink a YouTube video to responsive width -

wpf - PdfWriter.GetInstance throws System.NullReferenceException -