How to create a regular expression for a phone number in JavaScript, for example:

+71234567890 

Moreover, it is necessary that the expression select only numbers after +7 , that is, the search result will be 1234567890

  • 2
    This question should be closed, because it carries the author's request to do the work for him and has no value for the community. Please read the tips on how to ask a good question . - Yuri

2 answers 2

 var phone = '+71234567890', reg = /^\+7(\d{10})$/; console.log( phone.match(reg)[1] ); 

  • Let's try to joyfully launch a number from Australia: +61-2-1234 5678 :) - user207618
  • @Other, he did not ask for such a parse phone. He said, numbers after +7 , gave an example - I brought out the regular season - Yuri
  • The author cannot add all the numbers as an example, therefore an example. - user207618
  • @Other, well, let's start with the fact that he accepted the answer. If he wanted your type number, he would have written about it - Yuri
  • Enough of finding fault with my cavil! %) - user207618

 alert( '+71234567890'.match(/\+7([0-9]+)$/)[1] );