. Net Common regular expressions for favorites

Source: Internet
Author: User
Tags comments manual html tags lowercase regular expression

. Net Common regular expressions for favorites

Telephone number regular expression

(Mobile phone numbers, 3-4 area codes, 7-8 live video numbers, and 1-4 extension numbers are supported)

(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 Matching Chinese characters: [u4e00-u9fa5]
Note: matching Chinese characters is really a headache. It is easy to use this expression.

Match double byte characters (including Chinese characters): [^ x00-xff]
Comment: the regular expression that can be used to calculate the length of a string (a dual-byte length meter 2, ASCII character meter 1) matching a blank line: ns * r
Comment: the regular expression that can be used to delete blank rows matching HTML tags: <(S *?) [^>] *> .*? </1> | <.*? />
Note: the versions circulating on the Internet are too bad. The above can only match the part. For complex nested tags, there is still no way to match the regular expression of the first and last blank characters: ^ s * | s * $
Comment: It can be used to delete the blank characters (including spaces, tabs, break characters, and so on) at the beginning and end of a line. A very useful expression matches the regular expression of the Email address: w + ([-+.] w +) * @ w + ([-.] w + )*. w + ([-.] w + )*
Note: Regular expressions matching URLs are very useful in form verification: [a-zA-z] +: // [^ s] *
Comments: The versions circulating on the Internet have limited functions. The above can basically meet the needs of matching the account is legal (starting with a letter, may be 5-16 bytes, may be alphanumeric ): ^ [a-zA-Z] [a-zA-Z0-9 _] {} $
Comment: it is useful to match the domestic phone number during form verification: d {3}-d {8} | d {4}-d {7}
Comments: matching formats such as 0511-4405222 or 021-87888822 match Tencent QQ number: [1-9] [0-9] {4 ,}
Note: Tencent QQ numbers match the Chinese postal code from 10000: [1-9] d {5 }(?! D)
Note: China post code is a 6-digit matched ID card: d {15} | d {18}
Note: the ID card of China is a 15-or 18-bit matched IP address: d +. d +
Note: When extracting an IP address, it is useful to match a specific number:
^ [1-9] d * $ // match a positive integer
^-[1-9] d * $ // match a negative integer
^ -? [1-9] d * $ // match the integer
^ [1-9] d * | 0 $ // match a non-negative integer (positive integer + 0)
^-[1-9] d * | 0 $ // match a non-positive integer (negative integer + 0)
^ [1-9] d *. d * | 0. d * [1-9] d * $ // match the positive floating point number
^-([1-9] d *. d * | 0. d * [1-9] d *) $ // match the negative floating point number
^ -? ([1-9] d *. d * | 0. d * [1-9] d * | 0 ?. 0 + | 0) $ // Match floating point number
^ [1-9] d *. d * | 0. d * [1-9] d * | 0 ?. 0 + | 0 $ // Match non-negative floating point number (positive floating point number + 0)
^ (-([1-9] d *. d * | 0. d * [1-9] d *) | 0 ?. 0 + | 0 $ // match a non-positive floating point number (negative floating point number + 0)
Comments: It is useful when processing large amounts of data. Pay attention to correction when handling specific applications.

Match a specific string:
^ [A-Za-z] + $ // match A string consisting of 26 English letters
^ [A-Z] + $ // match a string consisting of 26 uppercase letters
^ [A-z] + $ // match a string consisting of 26 lowercase letters
^ [A-Za-z0-9] + $ // match a string consisting of digits and 26 letters
^ W + $ // match a string consisting of digits, 26 English letters, or underscores

 

"^ 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 lowercase letters
"^ [A-Za-z0-9] + $" // string consisting of digits and 26 letters
"^ W + $" // a string consisting of digits, 26 letters, or underscores
"^ [W-] + (. [w-] +) * @ [w-] + (. [w-] +) + $" // email address
"^ [A-zA-z] +: // (w + (-w +) *) (. (w + (-w + )*))*(? S *)? $ "// Url
/^ 13d {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 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] *

Why does the mobile phone number start with 13? Everyone knows that China Telecom mobile Post has not been split up before, and the Ministry of Posts and Telecommunications Resources are centrally scheduled by the Ministry of Posts and Telecommunications (now the Ministry of Information Industry. When assigning the number segment, I made some careful planning, which is roughly like this:
Starting with 10, China Telecom service number, such as 103 international semi-automatic registration, 108 International paid phone number, 10000 China Telecom Service Center, 10010 China Unicom service center, 10050 China Tietong service center, 10060 China Netcom service center, 10070 China Weitong service center, 10086 China Mobile service center, etc.
At the beginning of 11, assign a special service number, such as 110 police officers, 111 telecom internal tests, 112 for repairs, 113 and 115 domestic manual long-distance registration, 114 identification desk, 116 domestic manual long-distance query, and 117 for reporting, 119 fire alarms
At the beginning of 12, assign special civil numbers, such as 120 (hospital), 121 (weather forecast), 122 traffic accident warnings, 12312 protection of intellectual property reporting center, 12315 consumption complaint hotline, and 12319 urban construction service, 12348 legal consultation, 12358 Price Reporting Center, 12365 quality supervision, 12366 tax service, 12369 Environmental protection complaints, 126, 127, 128 and 129 paging stations (bpserver era)
Therefore, when assigned to a mobile phone user, the number segment starts with 13. Later, 130 ~ 133 for China Unicom, 134 ~ 139 is China Mobile, and 13800138000 is China Mobile.
A few days ago, a new number segment was launched: the number segment was allocated to China Unicom starting from 153, and the number segment was allocated to China Unicom starting from 158 and 159.
Start with 188 number segment for the TD-SCDMA standard of 3G mobile phone, will be selected in advance to test the user with "188" as the beginning of the mobile phone number, in Beijing, Qingdao, Xiamen, Baoding and other cities, the first trial of TD-SCDMA network.
(View the log "with a number starting with" 188 "TD-SCDMA standard mobile phone experience reading mail, watching mobile phone TV and other 3G business)
Other special number segments include:
16. Voice messaging, such as 160 China Telecom workers' information service access code, 166 voice mail service, 167 Jietong computer Internet service access code, 168 voice messaging service, and China Telecom Public Multimedia Network access code
17. Long-distance telephone service, for example, 170 domestic long-distance automatic call query desk, 173 domestic long-distance semi-automatic registration desk, 176 domestic long-distance semi-automatic query desk, and 177 domestic long-distance semi-automatic monitor desk, 179IP voice service access code
18. Some service desks, such as 180 postal services, 184 postal code query access codes, 185 telephone information service access codes of the State Post Office, 186 mobile service centers, and 188 fixed telephone toll stations, 189 China Telecom handles special servers (most of them have been disabled or changed to a new number)
19. Paging access, 191 UNICOM radio manual paging access code, 192 UNICOM radio automatic paging access code, and so on
, Telephone card service
In addition, numbers starting with 8 and 9 are also used as telecommunication and civil service numbers.
95. Financial and civil service number, 95501 Shenzhen Development Bank, 95502 Yongan property insurance, 95505 Tianan Insurance, 95508 Guangzhou Development Bank, 95511 Ping An Life Insurance, 95512 Ping An Property Insurance, 95515 Union Life Insurance, 95516 China UnionPay, 95518 China People's Insurance, 95519 China Life Insurance, 95522 Taikang Life Insurance, 95528 Pudong Development Bank, 95533 China Construction Bank, 95555 China Merchants Bank, 95556 China CITIC Bank, 95559 Bank of Communications, 95561 Industrial Bank, 95566 Bank of China, 95567 China Xinhua life insurance, 95568 China Minsheng Bank, 95569 Anbang Property Insurance, 95577 Huaxia Bank, 95585 China union financial insurance, 95588 Industrial and Commercial Bank of China, 95590 China land property insurance, 95595 Everbright Bank, 95596 Minsheng Life Insurance, 95599 Agricultural Bank of China, 95598 power supply services, 96100 civil affairs services, 96118 tourism complaints, 96178 honest government complaints, 96198 Agricultural Credit Union, 96310 urban management law enforcement, 95105366 China Railway Express, 95105768 Haikang life insurance
400. The company owner is assigned a pay-as-you-go call service. It is a fixed network operator that provides the called customer with a unique 400 number nationwide, then, call the number to the National Intelligent Network service specified by the called customer in advance (telephone number or call center. If an enterprise has applied for 400 million businesses, it will undoubtedly effectively improve its market image. However, if there is no call center behind it as a support, 400 will be just a number for future power transfer, and its value will be greatly reduced. For example: 4006789000 home delivery 4008108000 DHL Express 4008111111 SF Express 4008208388 UPS Express 4008861888 FedEx 4008888400 Shanghai Stock Exchange
800. For the centralized payment service of the recipient, the caller (Enterprise) pays the bills centrally, while the caller (customer) does not pay any fees. The use of telephone 800 fully embodies the advanced concept of "customer first" in enterprises, and its usage abroad is very common.
The above numbers are all allocated. Too many contents are not listed in detail. Some numbers have been upgraded, such as the telecommunications service desk, weather forecast, and postal service desk.

010123444444
And 02 start with three, and the rest start with four.
01x Beijing
02x Guangzhou, Shanghai, Tianjin, Chongqing, Shenyang, Nanjing, Wuhan, Chengdu
03xx Hebei, Henan, and Shanxi
04xx Liaoning, Jilin, Heilongjiang, Inner Mongolia
05xx Jiangsu, Shandong, Anhui, Zhejiang, and Fujian
06xx is this retained?
07xx Jiangxi, Guangxi, Hubei
08xx Sichuan, Guizhou
09xx Gansu Qinghai Xinjiang, Shaanxi

1. Ignore non-numeric (only numbers are left)
2. Determine whether the first two are both 0 or 86 and later than 11 digits. The first two are international codes. If the first two are after international codes, go to step 2.
3. The first is 0, and the second is not 0, which is a domestic code,
4. Based on the identity provided above

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)

Regular expressions allow Chinese characters, numbers, and punctuation! Can I enter a maximum of 200 characters, but cannot enter special characters?

Is it used in that environment? Js:
^ ([U4e00-u9fa5] | [0-9] | [,] | [,]) {0,200} $

To add punctuation marks, add
^ ([U4e00-u9fa5] | [0-9] | [,] | [,] | ["]) {0,200} $

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.