(1) Two special symbols '^' and '$'. Their role is to point out the beginning and end of a string. The example is as follows: "^ the": indicates all strings starting with "THE" ("there", "THE CAT", etc.); "of despair $": indicates the string ending with "of despair"; "^ ABC $ ": Indicates that the start and end are string of" abc "- huh, only" ABC ";" NOTICE ": indicates any string containing" Notice ". The last example, if you don't use two special characters, you are in any part of the string to find the string - you don't position it on a top. (2) Three symbols '*', ' ' and '?', Indicating the number of times of repeating one or a sequence character. They represent "no or more", "once or more" and "no or once". Here are a few examples: "ab *": means a string having a A back followed by zero or several b. ("A", "ab", "abbb", ...); "ab ": indicates a string having a A followed by at least one B or more; "ab?": Indicates a string has a A back Follow zero or one B; "a? B $": indicates that there is zero or one A followed one or more b at the end of the string. (3) The scope of use is enclosed by braces to indicate the range of repetitions. "AB {2}": means a string has a A follow 2 B ("abb"); "AB {2,}": indicates a string having a A follow at least 2 b; "AB {3, 5} ": Represents a string having a A follows 3 to 5 B. Note that you must specify the lower limit of the range (such as "{0, 2}" instead of "{, 2}"). Also, you may notice, '*', ' ' and '' '' correspond to "{0,}", "{1,}" and "{0, 1}".
(4) '|', representation "or" operation: "Hi | Hello": indicates "hi" or "hello" in a string: "BEF" or "CDEF" "(A | b) * c": Represents a string of "a" "b" mixed strings followed by "C"; (5) '.' Can replace any character: "a. [0-9] ": Represents a string with a" A "followed by an arbitrary character and a number;" ^. {3} $ ": indicates a string (length of 3 characters); (6) Brackets indicate certain characters to appear in a particular location in a string: "[ab]": indicates a string having a "A" or "B" (equivalent to "a | b"); "[AD ]:: Represents a string contains one of 'A' to 'd' (equivalent to "A | B | C | D" or "[ABCD]"); "^ [A-ZA-Z]" : Represents a string starting with letters; "[0-9]%": indicates a number in front of a percent sign; ", [A-ZA-Z0-9] $": indicates a string with one The comma is followed by a letter or numbers. * You can also use '^' in square brackets to indicate the characters that do not want to appear, '^' should be in the first place in square brackets. (, Such as "% [^ a-za-z]%" means that letters should not appear in two percent sign). In order to express verbatics, you must add transfer characters '/' before "^. $ () | * ? {/". Please note that in square brackets, no escape characters need. (7) other
/ b Match a word boundary, that is, the location of the words and spaces. For example, 'er / b' can match 'ER' in "Never", but do not match 'Er' in "Verb". / B matches non-word boundary. 'ER / B' can match 'Er' in "Verb", but cannot match 'Er' in "Never". / CX matches the control character indicated by x. For example, / cm matches a Control-M or an Enterprise. The value of x must be one of A-Z or A-Z. Otherwise, the C is treated as a primary 'c' character. / d Match a numeric character. Equivalent to [0-9]. / D Match a non-digital character. Equivalent to [^ 0-9]. / f Match a change page. Equivalent to / x0c and / cl. / n Match a newline. Equivalent to / x0a and / cj. / r Match a carriage return. Equivalent to / X0D and / cm. / s Match any blank character, including spaces, tabs, change page, and the like. Equivalent to [/ f / n / r / t / v]. / S Match any non-blank character. Equivalent to [^ / f / N / R / T / V]. / t matches a tab. Equivalent to / x09 and / ci. / v Match a vertical tab. Equivalent to / x0b and / ck. / w Match any word character that includes underscore. Equivalent to '[A-ZA-Z0-9_]'. / W Match any non-word characters. Equivalent to '[^ a-za-z0-9_]'. / XN matches n, where n is a hexadecimal escape value. The hexadecimal escape value must be a determined two numbers long. For example, '/ x41' matches "a". '/ x041' is equivalent to '/ x04' & "1". ASCII coding can be used in regular expressions. ./num matches NUM, where NUM is a positive integer. References to the acquired match. For example, '(.) / 1' matches two consecutive identical characters. / n identifies an octal escape value or a rearward reference. If the sub-expression of at least N before / N, n is a backward reference. Otherwise, if n is an octal number (0-7), then n is an eight-input escape value. / Nm identifies an octal escape value or a backward reference. If the / nm has at least IS Preceded by Least NM acquired a sub-expression, the nm is a backward reference. If there is at least n acquisitions before / nm, then n is a rear reference reference to the text M. If the previous conditions are not satisfied, if n and m are octal numbers (0-7), the / nm will match the eight-way escape value Nm. / Nml If n is an octal number (0-3), and M and L are eight-input numbers (0-7), match the eight-en-en-escaic value NML. / UN matches N, where N is a Unicode character represented by four hexadecimal numbers. For example, / u00A9 matches copyright symbol (?).
Test Mail is effective / W ([- .]/w ) *@/w ([-.]/w ) **w ([-.]/w ) * the date of the year of the year ( Correct input: 2003-12-25, leap year can be judged) a. The following correct input format: [2004-2-29], [2004-02-29 10:29:39 PM], [2004/12/31 ] ^ ((/ D {2} (([02468] [048])) [((((((((((((((0? [13578]) | (1 [02]) [/ - /// s]? ((0? [1-9]) | ([1-2] [0-9]) | (3 [01]))) | ((((((( 0? [469]) | (11)) [/ - /// s]? ((0? [1-9]) | ([1-2] [0-9]) | (30))) | (? 0 2 [/ - /// s] ((0 [1-9]) | ([1-2] [0-9]))??))) | (/ d {2} (([ [1235679]) ([13579]) [(((((((((0? [13578]) | (1 [02])) [/ - /// s ]? ((0? [1-9]) | ([1-2])) | (((((0? [469]) | (11)) [ / - / / / S]? ((0? [1-9]) | ([1-2] [0-9]) | (30))) | (0? 2 [/ - /// s] ((0? [1-9]) | (1 [0-9])))))))))))))))))))))))))))))))))))))))))) (/ s (((((((0? [1-9]) | 1 [0-2])) /: ([0-5] [0-9]) ((/ s) | (/: ([0-5] [0-9]) / s)) ([AM | PM | AM | PM] {2, 2})))))))) $ b. The following correct input format: [0001-12-31], [9999 09 30], [2002/03/03] ^ / d { 4} [/ - /// s]? (((0 [13578]) | (1 [02])) [/ - /// s]? (([0-2] [0-9]) (3 [01]))) | (((0 [469]) | (11)) [/ - /// s]? (([0-2] [0-9]) | (30)) ) | (02 [/ - /// s]? [0-2] [0-9])) $ Domestic phone number (this is a bit problem, correct format: 1234, 0123-12345678, 012-12345677 13856932145. The problem is that the mobile phone, now the following code inputs 4-11 digits are valid, have changed several times, it seems to be the cause of mathematics does not learn) (^ [0- 9] {3,4} / - [0-9] {3,8} $) | (^ [0-9] {3,8} $) | (^ / ([0-9] {3, 4 } /) [0-9] {3,8} $) | (^ 0 {0, 1} 13 [0-9] {9} $) Verify the 12-month input year in the year. Correct input: 01, 12, 08 ^ (0 [1-9] | 1 [0-2]) Verify the input of one month date. Correct input: 1-31 ^ ((0? [1-9]) | ((1 | 2) [0-9]) | 30 | 31) $ Filtering the script in the article Public Static String Filterscript (String CONTENT) {
String regexstr = @ "
Return Regex.Replace (Content, RegexStr, String.empty);} Import Email Address from Outlook
"
^ / d $
"
//
Non-negative integer (positive integer 0)
"
^ [0-9] * [1-9] [0-9] * $
"
//
Integer
"
^ ((- / d ) | (0 )) $
"
//
Non-positive integer (negative integer 0) "
^ - [0-9] * [1-9] [0-9] * $
"
//
Negative
"
^ -? / d $
"
//
Integer
"
^ / D (/./ d )? $
"
//
Non-doubling points (positive floating point 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
"
^ (((- / D (/. D )?) | (0 (/. 0 )?)) $
"
//
Non-positively floating point (load point 0)
"
^ (((((((((((([0-9] /. [0-9] * [1-9] [0-9] *) | ([0-9] * [1-9] [0-9] * / .[0-9] )| ([[0-9]*[1-9][0-9]* ))) $
"
//
Endo points
"
^ (-? / d ) (/./ d )? $
"
//
Floating point number
"
^ [A-ZA-Z] $
"
//
String consisting of 26 English letters
"
^ [A-z] $
"
//
String consisting of 26 English letters
"
^ [a-z] $
"
//
String consisting of 26 English letters
"
^ [A-ZA-Z0-9] $
"
//
String consisting of numbers and 26 English letters
"
^ / W $
"
//
String consisting of numbers, 26 English letters or underlined
"
^ [/ w -] (/. [/ w -] ) * @ [/ w -] (/. [/ w -] ) $
"
//
Email address
"
^ [A-ZA-Z] : / / (/ w / w ) *) (/. (/ w / w ) *) * (/? / s *)?
"
//
URL
/ ^
(D
{2}
|
di
{4}
)
-
(("
0
([["
1
-
9
]
{1}
))
|
(
1
[
1
|
2
]))
-
(([[[
0
-
2
]
1
-
9
]
{1}
))
|
(
3
[
0
|
1
]))
/
//
year month day
/ ^
(("
0
([["
1
-
9
]
{1}
))
|
(
1
[
1
|
2
]))
/
(([[[
0
-
2
]
1
-
9
]
{1}
))
|
(
3
[
0
|
1
]))
/
(D
{2}
|
di
{4}
$
/
//
Month / day / year
"
^ ([w -.] ) @ ([[0-9] {1,3}. [0-9] {1,3}. [0-9] {1,3}.) | ((( [w -] .) )) ([A-ZA-Z] {2, 4} | [0-9] {1,3}) (]?) $
"
//
Emil
"
(D -)? (D {4} -? D {7} | D {3} -? D {8} | ^ D {7, 8}) (- D )?
"
//
telephone number
"
^ (D {1, 2} | 1DD | 2 [0-4] D | 25 [0-5]). (D {1, 2} | 1DD | 2 [0-4] D | 25 [0-5 ]). (D {1, 2} | 1DD | 2 [0-4] D | 25 [0-5]). (D {1, 2} | 1DD | 2 [0-4] D | 25 [0 -5]) $
"
//
IP address