Regular Expression quick query table (ASP. NET)

Source: Internet
Author: User
Tags character classes alphanumeric characters

Source: RegExLib.com Regular Expression Cheat Sheet (. NET)

Metacharacters Description
^ Start position of matching string
$ End position of matching string
. Match any single character (except line break \ n)
| Alternate
{...} Specify the quantity to limit
[...] Character Set to be matched
(...) Logical grouping of expressions
* Matches zero or multiple previous expressions
+ Match one or more previous expressions
? Matches zero or a previous expression.
\ Put it before any of the preceding characters to match the character itself. Put it behind other special characters to indicate escape characters (see below)
Character escape Description
Original Character Except. $ ^ {[(|)]} * +? \ All other characters match themselves
\ Matching ringtone (alert) \ u0007
\ B Match a space \ u0008 in []. In other cases, match the word boundary (between \ w and \ W characters)
\ T Matching tabs \ u0009
\ R Carriage Return \ u000D
\ V Matching vertical tab \ u000B
\ F Match page feed \ u000C
\ N Match line break \ u000A
\ E Matched return key (character) \ u001B
\ 040 Matches the ASCII characters in octal notation (up to three digits). If there is no leading zero, only one digit or corresponding number corresponds to the number of a capture group, that is, backreference ). The \ 040 character represents a space.
\ X20 Matches ASCII characters in hexadecimal notation (two digits)
\ CC Matches ASCII control characters, for example, \ cC matches Ctrl + C
\ U0020 Match Unicode characters in hexadecimal notation
\* If the backslash is not followed by an escape character, it matches the character itself. For example, \ * is equivalent to \ x2A.
Character class Description
. Match any character except \ n.
[Aeiou] Match any character contained in a specific character set
[^ Aeiou] Match any character not contained in a specific character set
[0-9a-fA-F] Hyphens (-) are used to specify consecutive character ranges.
\ P {name} Match any character in the name character class specified by {name}
\ P {name} Match text that is not included in the group or block range specified by {name}
\ W Matching alphanumeric characters, equivalent to [a-zA-Z0-9] when specifying ECMAScript compatibility
\ W Matching non-English alphanumeric characters is equivalent to [^ a-zA-Z0-9] When ECMAScript compatibility is specified
\ S Matches any blank character. When ECMAScript compatibility is specified, it is equivalent to [\ f \ n \ r \ t \ v]
\ S Matches any non-blank characters. When ECMAScript compatibility is specified, it is equivalent to [^ \ f \ n \ r \ t \ v].
\ D Matches numeric characters. When ECMAScript compatibility is specified, it is equivalent to [0-9].
\ D Matching non-numeric characters is equivalent to [^ 0-9] When ECMAScript compatibility is specified.

English version:
Metacharacters Defined
MChar Definition
^ Start of a string.
$ End of a string.
. Any character (character t \ n newline)
| Alternation.
{...} Explicit quantifier notation.
[...] Explicit set of characters to match.
(...) Logical grouping of part of an expression.
* 0 or more of previous expression.
+ 1 or more of previous expression.
? 0 or 1 of previous expression; also forces minimal matching when an expression might match several strings within a search string.
\ Preceding one of the above, it makes it a literal instead of a special character. Preceding a special matching character, see below.
Metacharacter Examples
Pattern Sample Matches
^ Abc Abc, abcdefg, abc123 ,...
Abc $ Abc, endsinabc, 123abc ,...
A. c Abc, aac, acc, adc, aec ,...
Bill | ted Ted, bill
AB {2} c Abbc
A [bB] c Abc, aBc
(Abc) {2} Abcabc
AB * c Ac, abc, abbc, abbbc ,...
AB + c Abc, abbc, abbbc ,...
AB? C Ac, abc
A \ SC A c
Character Escapes http://tinyurl.com/5wm3wl
Escaped Char Description
Ordinary characters Characters other than. $ ^ {[(|)]} * +? \ Match themselves.
\ Matches a bell (alarm) \ u0007.
\ B Matches a backspace \ u0008 if in a []; otherwise matches a word boundary (between \ w and \ W characters ).
\ T Matches a tab \ u0009.
\ R Matches a carriage return \ u000D.
\ V Matches a vertical tab \ u000B.
\ F Matches a form feed \ u000C.
\ N Matches a new line \ u000A.
\ E Matches an escape \ u001B.
\ 040 Matches an ASCII character as octal (up to three digits); numbers with no leading zero are backreferences if they have only one digit or if they correspond to a capturing group number. (For more information, see Backreferences .) for example, the character \ 040 represents a space.
\ X20 Matches an ASCII character using hexadecimal representation (exactly two digits ).
\ CC Matches an ASCII control character; for example \ cC is control-C.
\ U0020 Matches a Unicode character using a hexadecimal representation (exactly four digits ).
\* When followed by a character that is not recognized as an escaped character, matches that character. For example,\*Is the same\ X2A.
Character Classes http://tinyurl.com/5ck4ll
Char Class Description
. Matches any character t \ n. If modified by the Singleline option, a period character matches any character. For more information, see Regular Expression Options.
[Aeiou] Matches any single character encoded in the specified set of characters.
[^ Aeiou] Matches any single character not in the specified set of characters.
[0-9a-fA-F] Use of a hyphen (-) allows specification of contiguous character ranges.
\ P {name} Matches any character in the named character class specified by {name}. Supported names are Unicode groups and block ranges. For example, Ll, Nd, Z, IsGreek, IsBoxDrawing.
\ P {name} Matches text not supported ded in groups and block ranges specified in {name }.
\ W Matches any word character. equivalent to the Unicode character categories [\ p {Ll} \ p {Lu} \ p {Lt} \ p {Lo} \ p {Nd} \ p {Pc}]. if ECMAScript-compliant behavior is specified with the ECMAScript option, \ w is equivalent to [a-zA-Z_0-9].
\ W Matches any nonword character. equivalent to the Unicode categories [^ \ p {Ll} \ p {Lu} \ p {Lt} \ p {Lo} \ p {Nd} \ p {Pc}]. if ECMAScript-compliant behavior is specified with the ECMAScript option, \ W is equivalent to [^ a-zA-Z_0-9].
\ S Matches any white-space character. equivalent to the Unicode character categories [\ f \ n \ r \ t \ v \ x85 \ p {Z}]. if ECMAScript-compliant behavior is specified with the ECMAScript option, \ s is equivalent to [\ f \ n \ r \ t \ v].
\ S Matches any non-white-space character. equivalent to the Unicode character categories [^ \ f \ n \ r \ t \ v \ x85 \ p {Z}]. if ECMAScript-compliant behavior is specified with the ECMAScript option, \ S is equivalent to [^ \ f \ n \ r \ t \ v].
\ D Matches any decimal digit. Equivalent to \ p {Nd} for Unicode and [0-9] for non-Unicode, ECMAScript behavior.
\ D Matches any nondigit. Equivalent to \ P {Nd} for Unicode and [^ 0-9] for non-Unicode, ECMAScript behavior.

Related Article

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.