I want to create a regexp for phone number in jQuery. My code:
var name_regexp = /\(\+?([0-9]{2})\)?([ .-]?)([0-9]{3})\2([0-9]{3})\2([0-9]{1,3})/;
if (($phone).match(name_regexp))
/*do sth */
And I use this expression because I want to support sth like that (+11)111111111, but I am trying to support:
- 555333222
- 555 333 222
- (11)555333222
- (11)555 333 222
- (+11)555333222
However, when I change expression to
var name_regexp = /\(?([0-9]{3})\)?([ .-]?)([0-9]{3})\2([0-9]{4})/;
I get no matches.