Last active
January 6, 2016 08:04
-
-
Save elizabeth-young/6549821 to your computer and use it in GitHub Desktop.
Some regular expressions - postcode, email, phone & mobile
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static class Regexes | |
{ | |
public const string Postcode = @"(GIR\s0AA)|(gir\s0aa)|((([A-PR-UWYZa-pr-uwyz][0-9][0-9]?)|(([A-PR-UWYZa-pr-uwyz][A-HK-Ya-hk-y][0-9][0-9]?)|(([A-PR-UWYZa-pr-uwyz][0-9][A-HJKSTUWa-hjkstuw])|([A-PR-UWYZa-pr-uwyz][A-HK-Ya-hk-y][0-9][ABEHMNPRVWXYabehmnprvwxy]))))\s{0,1}[0-9][ABD-HJLNP-UW-Zabd-hjlnp-uw-z]{2})"; | |
public const string Email = @"^([a-zA-Z0-9_\-\.]+)@{1}((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([a-zA-Z0-9\-]+\.)+))([a-zA-Z]{2,6}|[0-9]{1,3})$"; | |
public const string Mobile = @"^(((\+?44\s?[127]\d{2,3}|\(?0\d{4}\)?)\s?\d{3}\s?\d{3})|((\+?44\s?\d{3}|\(?0\d{3}\)?)\s?\d{3}\s?\d{4})|((\+?44\s?\d{2}|\(?0\d{2}\)?)\s?\d{4}\s?\d{4}))$"; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment