Friday 28 February 2014

Regular Expression Validators

In this article i would like to publish how to understand and write Regular Expression Validators.




Regular Expression Characters

Character
Description
*
Zero or more occurrences of the previous character or subexpression. For example,7*8 matches 7778 or just 8.
+
One or more occurrences of the previous character or subexpression. For example,7+8 matches 7778 but not 8.
()
Groups of subexpression that will be treated as a single element. For example, (78)+ matches 78 and 787878.
{m,n}
The previous character (or subexpression) can occur from m to n times. For example, A{1,3} matches A,AA, or AAA.
|
Either of two matches. For example,8|6 matches 8 or 6.
[]
Matches one character in a range of valid characters. For example,[A-C] matcher A,B or C.
[^]
Matches a character that isn’t in the given range for example, [A-B] matches any character except A and B.
.
Any character except newline. For example, .here matches where and there.
\s
Any whitespace character (such as a tab or space).
\S
Any nonwhite space character.
\d
Any digit character.
\D
Any character that isn’t a digit.
\w
Any “word character (letters, number or underscore).
\W
Any character that isn’t a “word” character (letter, number or underscore).

No comments :

Post a Comment