Useful field masks for common formats

I thought I’d start putting together a list of field masks that can be used for common formats. Feel free to add more here if you have some!

For details on how to use field masks, you can refer to this topic:

Field Masks

Email Address

Mask Type: Reg Ex

\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*

(Source: http://emailregex.com/ - .Net version)

6 Likes

Eircode (Republic of Ireland Postcode)

Mask Type: Reg Ex

([AC-FHKNPRTV-Y]\d{2}|D6W)[ -]?[0-9AC-FHKNPRTV-Y]{4}

(Source: https://stackoverflow.com/a/33913550/3399648, https://www.eircode.ie/)

5 Likes

UK Postcode

Mask Type: Reg Ex

(GIR ?0AA|[A-PR-UWYZ]([0-9]{1,2}|([A-HK-Y][0-9]([0-9ABEHMNPRV-Y])?)|[0-9][A-HJKPS-UW]) ?[0-9][ABD-HJLNP-UW-Z]{2})
6 Likes

UK Phone Number

Mask Type: Reg Ex

(\s*\(?0\d{4}\)?-?\s*\d{6}\s*)|(\s*\(?0\d{3}\)?-?\s*\d{3}?\s*\d{4}\s*)|(\s*\(?0\d{2}\)?-?\s*\d{4}?\s*\d{4}\s*)

This will accept a UK phone number in national format (i.e. typically as entered by a user or from a Caller ID device - not international format (+44 etc.)). It supports the following standard formats that are commonly used by different phone providers:

(note the actual numbers are not validated except for the leading 0)

Number Format Description
01234567890 no spaces / dashes
07123 4567890 space between STD code and number
5 digit STD codes
07123-4567890 dash between STD code and number
5 digit STD codes
0131 456 7890 space between STD code and number
4 digit STD codes
3+4 digit grouping for local number
0131-456 7890 dash between STD code and number
4 digit STD codes
3+4 digit grouping for local number
020 3459 7890 space between STD code and number
3 digit STD codes
4+4 digit grouping for local number
020-3459 7890 dash between STD code and number
3 digit STD codes
4+4 digit grouping for local number

(NOTE: Brackets for STD code (e.g. (01234) 567890) not supported even they are technically valid since no system uses that format these days and users do not typically write numbers in that format now)

(Source: https://en.wikipedia.org/wiki/Telephone_numbers_in_the_United_Kingdom#Format)

2 Likes

Just wanted to add this here in case you want to match phone numbers that have 9 to 10 digits and that aren’t specific to UK. Slightly edited mask from Stack Overflow.

Source Stack OverFlow RegEx Expression to match standard 10 digit phone number

// RegEx Mask allows 9-10 digits
[0-9]\d{2}-\d{3}-\d{3,4}

###-###-###
###-###-####


//Prompt Field
[?Phone;[0-9]\d{2}-\d{3}-\d{3,4};;ON;]

3 Likes

:heart_eyes:
This is great