Set of ASP. NET Regular Expressions
Set of ASP. NET Regular Expressions
1. The account is composed of ~ Z English letters (Case Insensitive), 0 ~ 9 is composed of numbers, points, minus signs, or underscores. The length is 3 ~ 18 characters, for example, kyzy_001
^ [A-zA-Z0-9.-_] {} $
2. The input box must contain numbers.
^ [0-9] {1,} $
3. Email format
/W + ([-+.] /W +) * @/W + ([-.] /W + )*/. /W + ([-.] /W + )*
4. Only two decimal numbers can be entered in the text box.
^ [0-9] +. [0-9] {0, 2} $
Match the time in the 24-hour format
(? <Hour> [0-2] {1}/d {1 }):(? <Min> [1-6] {1}/d {1 })
Match the standard monthly/annually crystal format
^ (0 [48]) | ([13579] [26]) | ([2468] [048]) 00) | ([0-9] [0-9] (0 [48]) | ([13579] [26]) | ([2468] [048]) -02-29) | (000 [1-9]) | (00 [1-9] [0-9]) | (0 [1-9] [0-9] [0-9]) | ([1-9] [0-9] [0-9] [0-9])-(0 [13578]) | (1 [02])-31) | (0 [1, 3-9]) | (1 [0-2])-(29 | 30 )) | (0 [1-9]) | (1 [0-2])-(0 [1-9]) | (1 [0-9]) | (2 [0-8]) $
========================================================== ========================================================== =
^/D {5} $
Five numeric numbers, such as the US Postal code.
^ (/D {5}) | (/d {5}-/d {4} $
5 numeric or 5 Numeric-dashes-4 numeric. Match the United States postal code in 5-digit format, or the United States postal code in 5-digit + 4-digit format.
^ (/D {5} (-/d {4 })? $
Same as the previous one, but more effective. Use? The four digits in the mode can be used as the optional part, instead of comparing two different modes (in another way ).
^ [+-]? /D + (/./d + )? $
Matches any real number with an optional symbol.
^ [+-]? /D */.? /D * $
It is the same as the previous one, but it also matches an empty string.
^ (20 | 21 | 22 | 23 | [01]/d): [0-5]/d $
Matches the time value in the 24-hour format.
//*.*/*/
Matching C-style comments /*...*/
Regular Expression for date and time judgment
Here is to judge the format of YYYY-MM-DD, basically the leap year and February and so on are taken into account.
^ (1 [6-9] | [2-9]/d)/d {2})-(0? [1, 13578] | 1 [02])-(0? [1-9] | [12]/d | 3 [01]) | (1 [6-9] | [2-9]/D) /d {2})-(0? [13456789] | 1 [012])-(0? [1-9] | [12]/d | 30) | (1 [6-9] | [2-9]/d)/d {2 }) -0? 2-(0? [1-9] | 1/d | 2 [0-8]) | (1 [6-9] | [2-9]/D) (0 [48] | [2468] [048] | [13579] [26]) | (16 | [2468] [048] | [3579] [26]) 00)-0? 2-29-) $
The following is a time verification
^ (1 [6-9] | [2-9]/d)/d {2})-(0? [1, 13578] | 1 [02])-(0? [1-9] | [12]/d | 3 [01]) | (1 [6-9] | [2-9]/D) /d {2})-(0? [13456789] | 1 [012])-(0? [1-9] | [12]/d | 30) | (1 [6-9] | [2-9]/d)/d {2 }) -0? 2-(0? [1-9] | 1/d | 2 [0-8]) | (1 [6-9] | [2-9]/D) (0 [48] | [2468] [048] | [13579] [26]) | (16 | [2468] [048] | [3579] [26]) 00)-0? 2-29-) (20 | 21 | 22 | 23 | [0-1]? /D): [0-5]? /D: [0-5]? /D $
Usage:
1. if (system. text. regularexpressions. regEx. match (str_check, "[a-zA-Z0-9] {1} [a-zA-Z0-9 _] {} [a-zA-Z0-9] {1} $ "). success = true)
{
Return true; // returns true if the matching is successful
}
2. Using system. Text. regularexpressions;
RegEx. ismatch (str_check, "[a-zA-Z0-9] {1} [a-zA-Z0-9 _] {} [a-zA-Z0-9] {1} $ ");