Useful Regex Expression

Salary Reqular Expressions:

SalaryPattern:RegExp = /^\d+(\.\d+)?$/;

Address Reqular Expressions:

AddressPattern:RegExp = /[^\n\t]\w+[\n]?$/;
var regAddressPattern = /\s?\w/;

Height Reqular Expressions:

var regHeightPattern = /^[1-9][‘][0][1-9][“]$/;
var regHeightPattern1 = /^[1-9][‘]\d[“]$/;
var regHeightPattern2 = /^[1-9][‘][1][0-1][“]$/;


var regHeightPattern = /^([0-9])([‘])([0][0-9])|([1][0-1])([“])$/;

Numbers only Reqular Expressions:

var regPincodePattern = /^\d+?$/;

Date Reqular Expressions:

var regDatepattern = /^((\d)?\d\/(\d)?\d\/\d{4})$/;

Time Reqular Expressions:

var rexTimePattern:RegExp = /^([0]?[1-9]|[1][0-1])(\:)([0-5][1-9])( )(AM|am)|(PM|pm)$/;
var rexTimePattern:RegExp = /^([0]?[1-9]|[1][0-2])\:[0-5]?[0-9]\ [A|P]M$/i;
var rexTimePattern:RegExp = /^((20|21|22|23|[0-1]\d)\:[0-5][0-9])?$/;

Check Floating Numbers Reqular Expressions:

var rexFloatingNumber:RegExp = /^[0-9]*\.?[0-9]*$/;

Date with Time regular expression (24 hours):

var rexDateTimePattern:RegExp = /^((\d)?\d\/(\d)?\d\/\d{4}) ([0-9]|[0-1][0-9]|[2][0-3]):([0-5][0-9])$/i;


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 )

Google+ photo

You are commenting using your Google+ 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