In this tutorial, We have list out Some commonly used regular expressions for RegularExpressionValidator Control in Asp.Net
Content
|
Regular Expression
|
Description
|
Email Address
|
\S+@\S+\.\S+
|
Defines an email address that requires an at symbol (@)
and a dot (.), and only allows non white space characters.
|
Password
|
\w+
|
Defines a password that allows any sequence
of word characters (letter, space, or underscore).
|
Specific-length password
|
\w{4-10}
|
Defines a password that must be at least
four characters long but no longer than ten characters.
|
Advance Password
|
[a-zA-Z]\w{3,9}
|
Defines a password that allows four to ten total
characters, as with the specific-length password.
The twist is that the first character must
fall in the range of a-z or A-Z (that is to say, it must start with a
nonaccented ordinary letter).
|
Another Advance Password
|
[a-zA-Z]\w*\d+\w*
|
Defines a password that starts with a letter character,
followed by zero or more word
characters, one or more digits, and then
zero or more word characters.
In short, it forces a password to contain a
number somewhere inside it. You could use a similar pattern to require two
numbers or any other special character.
|
Limited length field
|
\S{4,10}
|
Defines a string of four to ten characters
(like the password example), but it allows special characters (asterisks,
ampersands, and so on).
|
Social Security Number
|
\d{3}-\d{2}-\d{4}
|
Defines a sequence of three, two, and then
four digits, with each group separated by a hyphen. A similar pattern could
be used when requiring a phone number.
|
0 comments:
Post a Comment