Common Regular Expressions in ASP. NET

Source: Internet
Author: User

"^ \ 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 number
" ^ (-? \ 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 lowercase letters
"^ [A-Za-z0-9] + $" // string consisting of digits and 26 English letters
"^ \ W + $" // consists of digits and 26 English letters or a string consisting of 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 isvalidinclueno (string inclueno)
{
Const string regpattern = @ "^ (130 | 131 | 132 | 133 | 134 | 135 | 136 | 137 | 138 | 139) \ D {8} $ ";
Return RegEx. ismatch (regioneno, regpattern );
}

Regular Expression -- verify the mobile phone number
13 [0-9] {9}

When the mobile phone number is 86 or + 86
^ (\ + 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 from the information:
(H | H) (R | r) (E | E) (F | f) * = * ('| ")? (\ W | \/| \.) + ('| "| * |> )?

The email address in the extracted information:
\ W + ([-+.] \ W +) * @ \ W + ([-.] \ W + )*\. \ W + ([-.] \ W + )*

Extract the image link from the information:
(S | S) (R | r) (C | C) * = * ('| ")? (\ W | \/| \.) + ('| "| * |> )?

Extract the IP address from the information:
(\ D +) \. (\ D +)

Extract the Chinese mobile phone number from the information:
(86) * 0*13 \ D {9}

Chinese landline number extracted from the information:
(\ D {3, 4} \) | \ D {3, 4}-| \ s )? \ D {8}

Extract Chinese phone numbers (including mobile and landlines) from the Information ):
(\ D {3, 4} \) | \ D {3, 4}-| \ s )? \ D {7, 14}

Extract the Chinese postal code from the information:
[1-9] {1} (\ D +) {5}

The Chinese ID card number in the extracted information:
\ D {18} | \ D {15}

Extract an integer from the information:
\ D +

Extract the floating point number (decimal number) in the information ):
(-? \ D *)\.? \ D +

Extract any number from the information:
(-? \ D *) (\. \ D + )?

Extract Chinese strings from information:
[\ U4e00-\ u9fa5] *

Extract double-byte strings (Chinese characters) from the Information ):
[^ \ X00-\ xFF] *

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.