JS regular verification mailbox format details

  • 2020-03-29 23:52:13
  • OfStack

I. relevant code

function test()
  var temp = document.getElementById("text1");
  //Validation of E-mail
  var myreg = /^([a-zA-Z0-9]+[_|/_|/.]?)*[a-zA-Z0-9]+@([a-zA-Z0-9]+[_|/_|/.]?)*[a-zA-Z0-9]+/.[a-zA-Z]{2,3}$/;
    alert(' prompt /n/n Please enter a valid one E_mail ! ');
   return false;
 //Because of the same approach, only the relevant regular expressions are written below
 //Verification of mobile phone Numbers (two methods are provided)
 var mobile=/^((13[0-9]{1})|159|153)+/d{8}$/;
 var mobile1=/^(13+/d{9})|(159+/d{8})|(153+/d{8})$/;
 //Verification of area code
 var phoneAreaNum = /^/d{3,4}$/;
 //Verification of phone Numbers
 var phone =/^/d{7,8}$/;

Explain the relevant meaning
1.   /^$/ this is a general format.
        ^ matches the starting position of the input string; $matches the end of the input string

2. Input the functions to be implemented inside.
      * matches the preceding subexpression zero or more times;
      + matches the previous subexpression once or more;
      ? Matches the preceding subexpression zero or once;
      / d  Matching a numeric character is equivalent to [0-9]

Related articles: