Views:

Cleaning Samples

Removes all digits from a string

RegexReplace('stringinput', «\d», '')

Removes all characters from a string to only leave digits

RegexReplace('stringinput', «\D», '')

Removes duplicate white space (tabs, newlines, spaces, etc,) from a string

RegexReplace('stringinput', «\s+», ' ')

Removes all ascii characters from a string

RegexReplace('stringinput', «[^\u0000-\u007F]», '')

Removes all ascii characters and ascii control characters from a string

RegexReplace('stringinput', «[^\w\.@-]», '')

Formats a US telephone number

RegexReplace('US telephone number', «(\d{3})(\d{3})(\d{4})», «($1) $2-$3»)

Formats a US telephone number with extensions

RegexReplace('US telephone number', «^\D*(\d)\D*(\d)\D*(\d)\D*(\d)\D*(\d)\D*(\d)\D*(\d)\D*(\d)\D*(\d)\D*(\d)\D*(\d{2,})$», «+1 ($1$2$3) $4$5$6-$7$8$9$10 Ext $11»)

Validation Samples 

Validates an email address

 RegexIsMatch('Email address', «^[\w-]+(\.[\w-]+)*@([a-z0-9-]+(\.[a-z0-9-]+)*?\.[a-z]{2,6}|(\d{1,3}\.){3}\d{1,3})(:\d{4})?$»)


 
Validates an Uri

 RegexIsMatch('Uri', «(http|ftp|https):\/\/[\w\-_]+(\.[\w\-_]+)+([\w\-\.,@?^=%&:/~\+#]*[\w\-\@?^=%&/~\+#])?»)


 
Validates any whole or decimal number

 RegexIsMatch('Any whole or decimal number', «^([0-9]*|\d*\.\d{1}?\d*)$»)


 
Validates US Currency

 RegexIsMatch('US Currency', «^\$(\d{1,3}(\,\d{3})*|(\d+))(\.\d{2})?$»)


 
Validates one numeric digit

 RegexIsMatch('One numeric digit', «^\d$»)

 
Validates a percentage to 2 decimal places

 RegexIsMatch('A percentage to 2 decimal places ', «^( 100(?:\.0{1,2})? | 0*?\.\d{1,2} | \d{1,2}(?:\.\d{1,2})? )% $»)


 
Validates a password must be at least 8 characters, no more than 15 characters, and must include at least one upper case letter, one lower case letter, and one numeric digit

 RegexIsMatch('A password must be at least 8 characters, no more than 15 characters, and must include at least one upper case letter, one lower case letter, and one numeric digit', «^(?=.*\d)(?=.*[a-z])(?=.*[A-Z]).{8,15}$»)


 
Validates a UK vehicle registration

 RegexIsMatch('A UK vehicle registration', «^([A-Z]{3}\s?(\d{3}|\d{2}|d{1})\s?[A-Z])|([A-Z]\s?(\d{3}|\d{2}|\d{1})\s?[A-Z]{3})|(([A-HK-PRSVWY][A-HJ-PR-Y])\s?([0][2-9]|[1-9][0-9])\s?[A-HJ-PR-Z]{3})$»)


 
Validates alpha numeric values

 RegexIsMatch('Alpha numberic values', «^[a-zA-Z0-9]+$»)


 
Validates a UK National Insurance Number

 RegexIsMatch('A UK National Insurance Number', «^[A-CEGHJ-PR-TW-Z]{1}[A-CEGHJ-NPR-TW-Z]{1}[0-9]{6}[A-DFM]{0,1}$»)


 
Validates credit card numbers

 RegexIsMatch('Credit card numbers', «^((4\d{3})|(5[1-5]\d{2})|(6011))-?\d{4}-?\d{4}-?\d{4}|3[4,7]\d{13}$»)


 
Validates US telephone numbers

 RegexIsMatch('US telephone numbers', «^[01]?[- .]?\(?[2-9]\d{2}\)?[- .]?\d{3}[- .]?\d{4}$»)


 
Validates US Zip Codes

 RegexIsMatch('US Zip Codes', «(^(?!0{5})(\d{5})(?!-?0{4})(-?\d{4})?$)»)


 
Validates German Post Codes

 RegexIsMatch('German Post Codes', «\b((?:0[1-46-9]\d{3})|(?:[1-357-9]\d{4})|(?:[4][0-24-9]\d{3})|(?:[6][013-9]\d{3}))\b»)

 
Validates UK Post Codes

 RegexIsMatch('UK Post Codes', «^([A-PR-UWYZ0-9][A-HK-Y0-9][AEHMNPRTVXY0-9]?[ABEHMNPRVWXY0-9]? {1,2}[0-9][ABD-HJLN-UW-Z]{2}|GIR 0AA)$»)


 
Validates UK Telephone Number

 RegexIsMatch('UK Telephone Number', «(\s*\(?0\d{4}\)?(\s*|-)\d{3}(\s*|-)\d{3}\s*)|(\s*\(?0\d{3}\)?(\s*|-)\d{3}(\s*|-)\d{4}\s*)|(\s*(7|8)(\d{7}|\d{3}(\-|\s{1})\d{4})\s*)»)


 
Validates US Telephone Number

 RegexIsMatch('US Telephone Number', «^([0-9]( |-)?)?(\(?[0-9]{3}\)?|[0-9]{3})( |-)?([0-9]{3}( |-)?[0-9]{4}|[a-zA-Z0-9]{7})$»)


 
Validates date of birth (MM/DD/YYYY)

 RegexIsMatch('Date of birth (MM/DD/YYYY)', «^((0?[1-9]|1[012])[- /.](0?[1-9]|[12][0-9]|3[01])[- /.](19|20)?[0-9]{2})*$»)


 
Validates for digits only

 RegexIsMatch('Digits only', «^[0-9]*$»)


 
Validates US social security numbers

 RegexIsMatch('US social security number', «/^([0-9]{3}[-]*[0-9]{2}[-]*[0-9]{4})*$/»)