Last active
December 16, 2015 11:48
-
-
Save Kedrigern/5429708 to your computer and use it in GitHub Desktop.
Regexp matchich if string with street name has orientation number too.
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
| <?php | |
| /** | |
| * | |
| * Regexp matchich if string with street name has orientation number too. | |
| * Rules are for Czech Republic orientation numbers: | |
| * a) number for 0-999 | |
| * b) may be supplemented by one letter | |
| * @link http://www.czso.cz/csu/rso.nsf/i/cislo_orientacni | |
| * | |
| * @author: Ondřej Profant <ondrej.profant <> gmail.com>, 2013 | |
| * | |
| */ | |
| $strings = array ( | |
| "Šternberkova", | |
| "Šternberkova 10", | |
| "Šternberkova 2350/10", | |
| "Pod Sychrovem II", | |
| "Pod Sychrovem II 30", | |
| "Ulice 29", | |
| "Ulice 29b", | |
| "Ulice 29ab" | |
| ); | |
| $pattern = "|(\d)+\w?$|"; | |
| foreach( $strings as $s) { | |
| echo( (preg_match($pattern, trim($s)) ? "yes" : "no") . "\t$s\n"); | |
| } |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
V Nette¨forms: