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

Popular posts from this blog

c - Mpirun hangs when mpi send and recieve is put in a loop -

python - Apply coupon to a customer's subscription based on non-stripe related actions on the site -

java - Unable to get JDBC connection in Spring application to MySQL -