views:

46

answers:

3

Greetings,

I need to implement a jquery based validation for a text field that contains a phone number, for that I need the regular expression of these two strings, I am requesting this because I am very naive with RegEx:

First One:

0(5NN) NNN NN NN

Second One:

0(53N) NNN NN NN 

N means an integer between 0-9

+3  A: 
^0\(5\d{2}\) ?\d{3} ?\d{2} ?\d{2}$

and

^0\(53\d\) ?\d{3} ?\d{2} ?\d{2}$

will match. You can drop the ? if you are sure that there will always be space characters in the places you wrote them.

Tim Pietzcker
+1  A: 

This will match either one:

^0\(5\d\d\) \d\d\d \d\d \d\d$
richardtallent
+1  A: 

Why is the first not a superset of the second? Are we sure the (5NN) in the first is the full set of integers (5[0-9][0-9]), or is the 3 in the second combination (53[0-9]) significant in some way to exclude certain parts of [0-9]?

wbogacz