Created
August 14, 2025 08:14
-
-
Save milankragujevic/48b3605f6118826ffdcd114c1ab20102 to your computer and use it in GitHub Desktop.
Jedan nesveti regex koji validira srpske (fiksne i mobilne) brojeve telefona
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 | |
/** | |
* Jedan nesveti regex koji validira srpske (fiksne i mobilne) brojeve telefona | |
* Licenca: AGPL v3.0 | |
* Autor: Milan Kragujevic | |
*/ | |
if (!preg_match('/^(?:(?:\+381|00381)\s*(?:6\d(?:[\s.\/-]?\d){6,7}|(?:1\d|2\d|3\d)(?:[\s.\/-]?\d){5,7})|0\s*(?:6\d(?:[\s.\/-]?\d){6,7}|(?:1\d|2\d|3\d)(?:[\s.\/-]?\d){6,7}))$/', $body['phone'])) { | |
// telefon je nevalidan | |
} else { | |
// telefon je validan | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment