Skip to content

Instantly share code, notes, and snippets.

@aaryan79831014
Created November 3, 2022 18:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save aaryan79831014/85fe9ada49255e537a4ea34987e3d8de to your computer and use it in GitHub Desktop.
Save aaryan79831014/85fe9ada49255e537a4ea34987e3d8de to your computer and use it in GitHub Desktop.
void Main()
{
string pattern = @"^(AB|DD|DG|EH|FK|G|HS|IV|KA|KW|KY|ML|PA|PH|TD|ZE)\d{1,2}\s?(\d[\w]{2})";
string postcode = "AB6 5DD";
Match match = Regex.Match(postcode, pattern, RegexOptions.IgnoreCase);
if (match.Success)
{
"Scotland".Dump();
}
else
{
"England".Dump();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment