Created
October 27, 2022 12:33
-
-
Save yactouat/4fdab4582826b4b47bb723bedbd18e0e to your computer and use it in GitHub Desktop.
quick and dirty address validation
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
<?php | |
$regex = "/^[\w'\s\p{L}-]*$/u"; | |
$test = preg_match($regex, "8 rue du marché"); | |
$test2 = preg_match($regex, "5 rue de l'apostrophe"); | |
$test3 = preg_match($regex, "10 rue du passage \n à la ligne"); | |
echo "\n"; | |
echo !$test ? "test KO" : "test OK"; | |
echo "\n"; | |
echo "\n"; | |
echo !$test2 ? "test2 KO" : "test2 OK"; | |
echo "\n"; | |
echo "\n"; | |
echo !$test3 ? "test3 KO" : "test3 OK"; | |
echo "\n"; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment