Regular Expressions

Posted: November 22, 2008 in Computers and Internet

In the resent past I had to write some simple regular expressions.
So thought of sharing them with you.

An EMail Address Validator

This will validate the entered EMail address.

A Password Validator

This will validate the password to have at least 1 alphabetic character and 1 numeric digit, and altogether the password will be more than 6 characters long.

A Telephone Number Valdator

This will expect the telephone number to be in international format. For example (0094 777 123456).

A Simple Length Validator

This will allow only only 200 or lesser characters for input.

A Length Validator Which Works With Linefeed (Return, Enter)

This will validate and allow only 500 input even in a multi line field when linefeed (enter) is used in between.

A Date Validator

(0[1-9]|1[012])[- /.](0[1-9]|[12][0-9]|3[01])[- /.](19|20)\d\d

This will check for the date validness. The date format should be mm/dd/yyyy to correctly validate by this.

If the date format is required as yyyy/mm/dd then use the following.

(19|20)\d\d[- /.](0[1-9]|1[012])[- /.](0[1-9]|[12][0-9]|3[01])

Following are some good sites that you can refer for regular expression help.,M1


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s