Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Regular Expression to check the user input pattern

Tags:

regex

My users enter some numbers in a textbox. The numbers format is 09XXXXXXXXX. The numbers are separated by Comma. like 09121234567,09351234568. I use the Regular Expression below to check the user input.

^(09\d{9},?)+

Everything is ok but the problem is that if I enter 0912123456709351234568 it still matches this regexp. I want the user to enter at least one number without comma but if the numbers are more than one then it should be separated by comma. What is the right regexp?

like image 620
Pooya Yazdani Avatar asked Jul 10 '26 07:07

Pooya Yazdani


1 Answers

Try this pattern below,

^(09\d{9})(,09\d{9})*$

enter image description here

like image 172
John Woo Avatar answered Jul 12 '26 03:07

John Woo



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!