Header Ad

Friday, April 23, 2010

Java Script Regular Expressions

The following are the some of the java script regular expressions.

var Integer =/^[\-]?\d*$/;
var PositiveInteger =/^\d*$/;
var RealNumber = /^[\-]?\d*$|^[\-]?\d*\.\d*$/;
var PositiveRealNumber = /^\d*$|^\d*\.\d*$/;
var Currency = /^[\-]?[\$]?[\-]?\d+$|^[\-]?[\$]?[\-]?\d+\.\d*$|^[\-]?[\$]?[\-]?\d{1,3}(,\d{3})*\.\d{0,2}$/;
var Currency$ = /^[\-]?[\$]?[\-]?\d*$|^[\-]?[\$]?[\-]?\d*\.\d*$|^[\-]?[\$]?[\-]?\d{1,3}(,\d{3})*\.\d{0,2}$/;
var PositiveCurrency = /^[\$]?\d*$|^[\$]?\d*\.\d*$|^[\$]?\d{1,3}(,\d{3})*\.\d{0,2}$/;
var PositiveCurrency$ = /^[\$]?\d*$|^[\$]?\d*\.\d*$|^[\$]?\d{1,3}(,\d{3})*\.\d{0,2}$/;
var GeneralNumber = /^\d*$|^\d*\.\d*$/;
var FixedNumber = /^\d*\.\d*$/;
var StandardNumber = /^\d{1,3}(,\d{3})*\.\d{2}$/;
var Percentage = /^\d*$|\d{1,3}(,\d{3})*\.\d{1,3}[\%]?/;
var Alphabet = /^\b[a-z\s\.]*$/i
var Address = /./
var CreditCardNo = /^[0-9]{16}$/;
var AlphaNumeric = /^[a-z_0-9\s]*$/i
var Phone = /^\d{10}$|^\d{3}\-\d{3}\-\d{4}$/;
var LongPhoneFormat = /^\d{10}$|^[\(]?\d{3}[\)]?[\-\s]*\d{3}[\-\s]?\d{4}$/;
var StandardPhoneFormat = /^\d{10}$|^\d{3}[\-\s]{1,2}\d{3}[\-\s]?\d{4}$/;
var ZipCode1 = /^[0-9]{5}$/;
var ZipCode2 = /^[0-9]{4}$/;
var Email = /^[a-z_0-9]?[a-z_0-9\.\-\']+@[a-z_0-9\.\-]+\.[a-z_0-9]{2,3}$/i
var MultiEmail =/^[a-z_0-9\@\.\,\;\:\#\']$/i
var SSN = /^\d{3}[\-\s]*\d{2}[\-\s]*\d{4}$/;
var DateOfBirth=/^\d{2}[\\\s]*\d{2}[\\\s]*\d{4}$/;
var urlPattern = /^(?:(?:ftp|https?):\/\/)?(?:[a-z0-9](?:[-a-z0-9]*[a-z0-9])?\.)+(?:com|edu|biz|org|gov|int|info|mil|net|name|museum|coop|aero|[a-z][a-z])\b(?:\d+)?(?:\/[^<>()\[\]{}\s\x7f-\xff]*(?:[.,?]+[^<>()\[\]{}\s\x7f-\xff]+)*)?/;

No comments: