Regular expression collation based on PHP (bottom)

Source: Internet
Author: User

A line break matches a newline character. Equivalent to \x0a and \CJ.
+ \ R matches a carriage return character. Equivalent to \x0d and \cm.
The \s matches any whitespace character, including spaces, tabs, page breaks, and so on. equivalent to [\f\n\r\t\v].
\s matches any non-whitespace character. equivalent to [^ \f\n\r\t\v].
+ \ t matches a tab. Equivalent to \x09 and \ci.
The \v matches a vertical tab. Equivalent to \x0b and \ck.
The \w matches any word character that includes an underscore. Equivalent to ' [a-za-z0-9_] '.
\w matches any non-word character. Equivalent to ' [^a-za-z0-9_] '.
The \XN matches n, where n is the hexadecimal escape value. The hexadecimal escape value must be two digits long for a determination.
The \num matches num, where num is a positive integer. A reference to the obtained match.
\ n identifies an octal escape value or a back reference. N is a back reference if \ n has at least one of the first obtained sub-expressions. Otherwise, if n is the octal number (0-7), N is an octal escape value.
The \NM identifies an octal escape value or a back reference. If at least \nm was preceded by at least nm, then NM is a back reference. If there are at least N fetches before \nm, then N is a back reference followed by the literal m. If none of the preceding conditions are met, if both N and M are octal digits (0-7), then \nm will match the octal escape value nm.
\NML if n is an octal number (0-3) and both M and L are octal digits (0-7), the octal escape value NML is matched.
The \un matches n, where N is a Unicode character represented by four hexadecimal digits.
75 regular expressions that match Chinese characters: [U4E00-U9FA5]
76 matching double-byte characters (including kanji): [^x00-xff]
77 Regular expression matching blank line: n[s|] *r
78 Regular Expressions Matching HTML tags:/< (. *) >.*</1>|< (. *)/>/
79 Regular expressions that match the leading and trailing spaces: (^s*) | (s*$)
80 regular expression matching email address: w+ ([-+.] w+) *@w+ ([-.] w+) *.w+ ([-.] w+) *
81 regular expression matching URL URL:/http ([w-]+.) +[w-]+ (/[w-./?%&=]*)?
82 use regular expressions to restrict the entry of text boxes in a Web page form:
83 use Regular expression restrictions to enter only Chinese:
Onkeyup= "Value=value.replace (/[^u4e00-u9fa5]/g, ')"
84 restrict input of full-width characters with regular expressions only:
Onkeyup= "Value=value.replace (/[^uff00-uffff]/g, ')"
85 You can only enter numbers with regular expression restrictions:
Onkeyup= "Value=value.replace (/[^d]/g, ')" onbeforepaste= "Clipboarddata.setdata (' text ', Clipboarddata.getdata (' Text '). Replace (/[^d]/g, ')) "
86 use regular expression restrictions to enter only numbers and English:
Onkeyup= "Value=value.replace (/[w]/g, ')" onbeforepaste= "Clipboarddata.setdata (' text ', Clipboarddata.getdata (' Text '). Replace (/[^d]/g, ')) "
87 ========= Common Regular type
88 Regular expressions that match Chinese characters: [\U4E00-\U9FA5]
89 matching double-byte characters (including kanji): [^\x00-\xff]
90 regular expression matching blank line: \n[\s|] *\r
91 Regular Expressions Matching HTML tags:/< (. *) >.*<\/\1>|< (. *) \/>/
92 Regular expressions that match the leading and trailing spaces: (^\s*) | (\s*$)
93 Regular expression matching IP address:/(\d+) \. (\d+) \. (\d+) \. (\d+)/g//
94 Regular expression matching email address: \w+ ([-+.] \w+) *@\w+ ([-.] \w+) *\.\w+ ([-.] \w+) *
95 regular expression matching URL URL:/http (/[\w-]+\.) +[\w-]+ (/[\w-./?%&=]*)?
$ SQL statement: ^ (select|drop|delete|create|update|insert). *$
97 non-negative integers: ^\d+$
98 positive integers: ^[0-9]*[1-9][0-9]*$
99 non-positive integers: ^ ((-\d+) | ( 0+)) $
100 Negative integers: ^-[0-9]*[1-9][0-9]*$
101 Integers: ^-?\d+$
102 non-negative floating point number: ^\d+ (\.\d+)? $
103 positive floating point number: ^ (0-9) +\.[ 0-9]*[1-9][0-9]*) | ([0-9]*[1-9][0-9]*\. [0-9]+) | ([0-9]*[1-9][0-9]*)) $
104 non-positive floating-point number: ^ ((-\d+\.\d+)?) | (0+ (\.0+)?)) $
105 Negative floating point number: ^ (-(regular floating point)) $
106 English string: ^[a-za-z]+$
107 English Capitalization string: ^[a-z]+$
108 English lowercase string: ^[a-z]+$
109 English characters number string: ^[a-za-z0-9]+$
110-digit Plus dash string: ^\w+$
111 e-mail address: ^[\w-]+ (\.[ \w-]+) *@[\w-]+ (\.[ \w-]+) +$
url:^[a-za-z]+://(\w+ (-\w+) *) (\. ( \w+ (-\w+) *) * (\?\s*)? $
113 ^http:\/\/[a-za-z0-9]+\. [a-za-z0-9]+[\/=\?%\ -&_~ ' @[\]\ ': +!] * ([^<>\ "\"]) *$
114 Post Code: ^[1-9]\d{5}$
115 Chinese: ^[\u0391-\uffe5]+$
116 Phone Number: ^ ((\d{2,3}\) | ( \d{3}\-))? (\ (0\d{2,3}\) |0\d{2,3}-)? [1-9]\d{6,7} (\-\d{1,4})? $
117 Mobile Number: ^ ((\d{2,3}\) | ( \d{3}\-))? 13\d{9}$
118 double-byte characters (including kanji): ^\x00-\xff
119 Matching trailing spaces: (^\s*) | (\s*$) (Trim function like VBScript)
120 Matching HTML tags:< (. *) >.*<\/\1>|< (. *) \/>
121 Matching blank line: \n[\s|] *\r
122 the network link in the extracted information: (h| H) (r| R) (e| E) (f| F) *= * (' | ')? (\w|\\|\/|\.) + (' | ' | *|>)?
123 e-mail address in Extract information: \w+ ([-+.] \w+) *@\w+ ([-.] \w+) *\.\w+ ([-.] \w+) *
124 extract information from the image link: (s| S) (r| R) (c| C) *= * (' | ')? (\w|\\|\/|\.) + (' | ' | *|>)?
125 Extract the IP address in the information: (\d+) \. (\d+) \. (\d+) \. (\d+)
126 Chinese mobile phone number in extracting information: (*0*13\D{9)

The above is not An Shu collation of regular expressions, if the previous said the regular some forgotten can be seen in the "PHP-based regular expression (bottom)"

Common regular expression collation based on PHP (bottom)

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.