Determines whether the e-mail address//^ represents the beginning of the match//\w+ \w means matching an English letter or number, + means matching the preceding element one or more times/@ means matching the @ symbol//[a-z0-9]+ [a-z0-9] Represents a match letter A-Z or 0-9,+ that matches the preceding element one or more times//\. Represents a.//[a-z]+ that matches any one of the letters A-Z, + means that matches the preceding element one or more times//{1,3} matches the contents of the preceding parenthesis 1 times-3 times//$ to match the End Function Isemail (emailstr ) { var emailreg =/^\[email protected][a-z0-9]+ (\.[ a-z]+) {1,3}$/; if (Emailreg.test (EMAILSTR)) { Console.log ("The email address you entered is in the correct format! ") return true; } else { Console.log ("The email address you entered is not formatted correctly") return false; }} Determine whether the cell phone number//1 is the beginning of the first;//2--The second can be 3,4,5,7,8, any one of them;//3--ends with 9 integers of 0-9. function Isphone (phoneint) { var myreg=/^[1][3,4,5,7,8][0-9]{9}$/; if (Myreg.test (Phoneint)) { Console.log ("The phone number you entered is in the correct format! ") return true; } else { Console.log ("The phone number you entered is not in the correct format! ") return false; } }
Ife_part2_javascript_ Regular Expression usage (email/mobile number)