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

python - how we can use ajax() in views.py in django? -

matlab - Using loops to get multiple values into a cell -

python - Sequence Pattern recognition with Pybrain -