Friday, 28 February 2014

Commonly Used Regular Expressions

In this article i would like to publish an article that Commonly Used Regular Expressions


Commonly Used Regular Expressions

Content
Regular Expression
Description
E-mail address*
\S+@\S+\.\S+
Check for an at (@) sign and dot (.) and allow nonwhite space characters only.
Password
\w+
Any sequence of one or more word characters (letter, space or underscore).
Specific-length password
\w{4,10}
A password that must be atleast four characters long but no longer than ten characters.
Advanced password
[a-zA-Z]\w{3,9}
As with the specific-length password, this regular expression will allow four to ten total characters. The twist is that the first character must fall in the range of a-z or A-Z (this is to say. it must start with a non accented ordinary letter).
Another advanced password
[a-zA-Z]\w*\d+\w*
This password 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 one or more numbers somewhere inside it. You could use a similar pattern to require two numbers or any other special character.

No comments :

Post a Comment