I use this ^((\d-\d{3})|(\d{1,3}))\-\d{3}-\d{7}$
regex to validate phone numbers.
However it does not accept the following number which is valid. What is the problem? Could it have to do with the zeros at the end?
90-312-2488900
Your regexp seems to work properly.
Maybe the problem is in the last space in your example. Try to remove it with string.Trim, or add \s*
to your regexp (or even add it between every groups of numbers.
The space at the end of your example is what is causing it to not match. Go to regexpal and type in your regex. When you try your example, it will show you what matches and what doesn't. Without the space, you are good to go. As JleruOHep recommended, try trimming the string, or allow whitespace in your regex.
Here is your phone number without whitespace at the end.
The yellow highlight is what matches.