Skip to content

Instantly share code, notes, and snippets.

@GJNilsen
Last active February 27, 2016 14:47
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 GJNilsen/c52aee71dbb60c43e563 to your computer and use it in GitHub Desktop.
Save GJNilsen/c52aee71dbb60c43e563 to your computer and use it in GitHub Desktop.
Regex Collection
Norwegian Address Format
/([^,]+),\s*(\d{4})\s*([^,]+)(?:,\s*([^,]+))?/u
Street Name xx, zip City, Country
// PHP usage
preg_match("/([^,]+),\\s*(\\d{4})\\s*([^,]+)(?:,\\s*([^,]+))?/u", $location, $matches);
if ($matches) {
$streetAddress = $matches[1];
$zip = $matches[2];
$city = $matches[3];
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment