Telephone number regular expression
Regular expression of phone number (mobile phone number, 3-4 area code, 7-8 live video number, 1-4 extension code)
(D {11}) | ^ (d {7, 8}) | (d {4} | d {3})-(d {7, 8 }) | (d {4} | d {3})-(d {7, 8 }) -(d {4} | d {3} | d {2} | d {1}) | (d {7, 8 }) -(d {4} | d {3} | d {2} | d {1}) $)
Matching format:
11-digit mobile phone number
3-4-bit area code, 7-8 live video numbers, 1-4 ext.
For example: 12345678901, 1234-12345678-1234
Regular expression -- verify mobile phone number: 13 [0-9] {9}
If the mobile phone number is 86 or + 86 before it is implemented: ^ (+ 86) | (86 ))? (13) d {9} $
Verify the phone number and phone number at the same time: (^ (d {3, 4 }-)? D {7,8}) $ | (13 [0-9] {9 })
Extract the network link in the Information: (h | H) (r | R) (e | E) (f | F) * = * ('| ")? (W | \ |/|.) + ('| "| * |> )?
Email address in the extracted information: w + ([-+.] w +) * @ w + ([-.] w + )*. w + ([-.] w + )*
Extract the image link in the Information: (s | S) (r | R) (c | C) * = * ('| ")? (W | \ |/|.) + ('| "| * |> )?
Extract the IP address in The Information: (d +). (d +)
Extract the Chinese mobile phone number from The Information: (86) * 0 * 13d {9}
Extracted Chinese landline numbers: (d {3, 4}) | d {3, 4}-| s )? D {8}
Extract Chinese phone numbers (including mobile and landline phones) from the Information: (d {3, 4}) | d {3, 4}-| s )? D {7, 14}
Extracted Chinese Zip code: [1-9] {1} (d +) {5}
Extracted Chinese ID card number: d {18} | d {15}
Extract the integer in the information: d +
Extract floating point numbers (decimal places) in The Information ):(-? D *).? D +
Extract any number from The Information :(-? D *) (. d + )?
Extract Chinese strings from information: [u4e00-u9fa5] *
Double byte string in extracted information (Chinese character): [^ x00-xff] *
Verify the regular expression of the mobile phone number and phone number
The domestic fixed telephone and fax rules are basically in the format of "-" + telephone number with a 0 area code connector. In addition, there may also be a location code with a 3-digit or 4-digit area code, the telephone number has 7 and 8 bits. Other formats include those with no front or connector, or those with no front or extension number, or add "86" to the front;
Area code: the first 0, followed by 2-3 digits: 0d {2, 3}
Phone number: 7-8 digits: d {7, 8}
Extension number: Usually three digits: d {3 ,}
In this way, the connection is to verify the regular expression of the phone:/^ (0d {2, 3}) (d {7, 8}) (-(d {3 ,}))? $/
The phone number starts with 1, the second digit is 3 or 5, and the last digit is 9 digits. Then:/^ 1 [35] d {9} $/
See a strong verification :( ^ (d {2, 4} [-_ --]?)? D {3, 8} ([-_ --]? D {3, 8 })? ([-_ --]? D {1, 7 })? $) | (^ 0? 1 [35] d {9} $)
This expression can verify the characters that accidentally write the hyphen "-" or underscore.
Verify the regular expression of the phone number
Telephone number regular expression
The regular expression is as follows:
(^ (D {2, 4} [-_ --]?)? D {3, 8} ([-_ --]? D {3, 8 })? ([-_ --]? D {1, 7 })? $) | (^ 0? 1 [35] d {9} $)
Area code + landline number + extension number: regexp = "^ (0 [0-9] {2, 3 }-)? ([2-9] [0-9] {6, 7}) + (-[0-9] {1, 4 })? $"
Mobile phone number (China mobile phone number): regexp = "^ (d {3}) | (d {3 }-))? 13 [456789] d {8} | 15 [89] d {8 }"
All mobile phone numbers: regexp = "^ (d {3}) | (d {3 }-))? 13 [0-9] d {8} | 15 [89] d {8} "(two new section 158,159 is added)
Verify the regular expression of the phone number
<Script language = "javascript tutorial">
Function checkphone (tel ){
Var str = tel;
// In JavaScript, regular expressions can only start and end with "/", but cannot use double quotation marks: website source code
Var Expression =/(d {3}-) (d {8}) $ | (d {4}-) (d {7}) $ /; // match the specified number of digits in the string. (d {8}) $ indicates that the string ends with 8 digits.
Var objExp = new RegExp (Expression );
If (objExp. test (str) = true ){
Return true;
} Else {
Return false;
}
}
</Script>
This site is organized and partially original. It is reprinted with instructions from www.111cn.net.