Regular Expressions for mobile phone numbers and phone numbers

Source: Internet
Author: User
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
"^\d+$"    // Non-negative integer (positive integer + 0)
"^[0-9]*[1-9][0-9]*$"    // Positive integer
"^((-\d+)|(0+))$"    // Non-positive integer (negative integer + 0)
"^-[0-9]*[1-9][0-9]*$"    // Negative integer
"^-?\d+$"      // Integer
"^\d+(\.\d+)?$"    // Non-negative floating point number (Positive floating point number + 0)
"^(([0-9]+\.[0-9]*[1-9][0-9]*)|([0-9]*[1-9][0-9]*\.[0-9]+)|([0-9]*[1-9][0-9]*))$"    // Positive floating point number
"^((-\d+(\.\d+)?)|(0+(\.0+)?))$"    // Non-Positive floating point number (negative floating point number + 0)
"^(-(([0-9]+\.[0-9]*[1-9][0-9]*)|([0-9]*[1-9][0-9]*\.[0-9]+)|([0-9]*[1-9][0-9]*)))$"    // Negative floating point
Quantity "^(-?\d+)(\.\d+)?$"    // Floating point number
"^[A-Za-z]+$"    // A string consisting of 26 English letters
"^[A-Z]+$"    // A string consisting of 26 uppercase letters
"^[a-z]+$"    // A string consisting of 26 lower-case letters
"^[A-Za-z0-9]+$"    // A string consisting of a number and 26 English letters
"^\w+$"    // A string consisting of digits, 26 English letters, or underscores
"^[\w-]+(\.[\w-]+)*@[\w-]+(\.[\w-]+)+$"      // Email address
"^[a-zA-z]+://(\w+(-\w+)*)(\.(\w+(-\w+)*))*(\?\S*)?$"   //url 
/^ 13 \ D {9} $/GI mobile phone number Regular Expression
public
static bool
IsValidMobileNo( string
MobileNo)    {
    const
string regPattern =
@"^(130|131|132|133|134|135|136|137|138|139)\d{8}$" ;
    return
Regex.IsMatch(MobileNo, regPattern);    }
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*13 \ D {9}
Extracted Chinese landline numbers from the information: (\ 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}
Chinese ID card number in the extracted information: \ D {18} | \ D {15}
Extract the integer \ D + from the information.
Extract floating point numbers (decimal places) in the Information ):(-? \ D *)\.? \ D +
Extract any number from the information :(-? \ D *) (\. \ D + )?
Extract the Chinese string from the information: [\ u4e00-\ u9fa5] *
Double-byte string (Chinese character) in the extracted information: [^ \ x00-\ xFF] *

Original article: http://www.cnblogs.com/xyzhuzhou/archive/2012/05/08/2490388.html

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.