Last active
February 27, 2016 14:47
-
-
Save GJNilsen/c52aee71dbb60c43e563 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
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