java - Regular expression for phone number validation -
Hello, I need regex for phone number verification for the following format
+ 1-646 -222-3333 I have written the expression like
^ (+) ([0- 9] {3} - [0- 9] {3} - [0- 9] {4}) But its not working Do I know why I did wrong?
Try it out:
string str = "+ 1-646 -222-3333 "; If (str.matches ("\\ + \\ d - \\ d {3} - \\ d {3} - \\ d {4}")) {System.out.println ("valid number"); } Else {System.out.println ("Invalid Number"); }
Comments
Post a Comment