Regular Expressions

Useful information for users

Regular Expressions

Postby bulat » Mon Jun 29, 2009 9:26 pm

Find examples and share your regular expressions here.
Best Regards
Bulat
bulat
Site Admin
 
Posts: 38
Joined: Fri Nov 28, 2008 6:50 pm

UK Customer Data

Postby bulat » Fri Oct 23, 2009 2:34 pm

Here are a couple of regular expressions for UK customer data that I find useful for marketing files validation:

UK Postcode (From BS7666 Address):
Code: Select all
^(GIR 0AA|[A-PR-UWYZ]([0-9]{1,2}|([A-HK-Y][0-9]|[A-HK-Y][0-9]([0-9]|[ABEHMNPRV-Y]))|[0-9][A-HJKS-UW]) [0-9][ABD-HJLNP-UW-Z]{2})$


UK Postcode (simplified version):
Code: Select all
^[A-Z]{1,2}[0-9R][0-9A-Z]?\s[0-9][A-Z]{2}$


Email:
Code: Select all
^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,4}$


UK Telephone Number (including mobile):
Code: Select all
^(\+44)?(0|\(0\))[12378](\d[\-\(\)\.]?\s?){8,9}$

Matches: +44(0)1222333444; 02222333444; 0(1222) 333-444

UK Mobile Number:
Code: Select all
^(\+44)?(0|\(0\))7(\d[\-\(\)\.]?\s?){9}$


Surname (Now matches Irish and Scottish surnames) :
Code: Select all
^[A-Z]([']|[a-z]{0,2})?[A-Z]?[a-z]+((\s|\-)[A-Z][a-zA-Z]+){0,2}$
Best Regards
Bulat
bulat
Site Admin
 
Posts: 38
Joined: Fri Nov 28, 2008 6:50 pm

US Customer Data

Postby bulat » Wed Nov 11, 2009 11:58 am

Zip Code (5/5+4 formats):

Code: Select all
^(\d{5})(-\d{4})?$
Best Regards
Bulat
bulat
Site Admin
 
Posts: 38
Joined: Fri Nov 28, 2008 6:50 pm

Canadian Customer

Postby bulat » Wed Nov 11, 2009 12:03 pm

Postcode:
Code: Select all
^[ABCEGHJKLMNPRSTVXY]\d[A-Z] \d[A-Z]\d$
Best Regards
Bulat
bulat
Site Admin
 
Posts: 38
Joined: Fri Nov 28, 2008 6:50 pm

MAC Address & Date

Postby RacerX64 » Sun May 30, 2010 2:13 am

MAC Address:
Code: Select all
([0-9a-fA-F][0-9a-fA-F]){5}([0-9a-fA-F][0-9a-fA-F])


Date:
Code: Select all
^((((0?[1-9]|[12]\d|3[01])[\.\-\/](0?[13578]|1[02])[\.\-\/]((1[6-9]|[2-9]\d)?\d{2}))|((0?[1-9]|[12]\d|30)[\.\-\/](0?[13456789]|1[012])[\.\-\/]((1[6-9]|[2-9]\d)?\d{2}))|((0?[1-9]|1\d|2[0-8])[\.\-\/]0?2[\.\-\/]((1[6-9]|[2-9]\d)?\d{2}))|(29[\.\-\/]0?2[\.\-\/]((1[6-9]|[2-9]\d)?(0[48]|[2468][048]|[13579][26])|((16|[2468][048]|[3579][26])00)|00)))|(((0[1-9]|[12]\d|3[01])(0[13578]|1[02])((1[6-9]|[2-9]\d)?\d{2}))|((0[1-9]|[12]\d|30)(0[13456789]|1[012])((1[6-9]|[2-9]\d)?\d{2}))|((0[1-9]|1\d|2[0-8])02((1[6-9]|[2-9]\d)?\d{2}))|(2902((1[6-9]|[2-9]\d)?(0[48]|[2468][048]|[13579][26])|((16|[2468][048]|[3579][26])00)|00))))$


UPD (Bulat): I would not recommend using regular expressions for date validation. It is better to set a date range through Value data rule and specify date format in the Field Details form.
Last edited by bulat on Sat Jul 24, 2010 9:57 am, edited 3 times in total.
Reason: enclose regular expressions in code + comment on validation of dates
RacerX64
 
Posts: 1
Joined: Sun May 30, 2010 2:09 am


Return to Documentation

Who is online

Users browsing this forum: No registered users and 1 guest

cron