Skip to content

Instantly share code, notes, and snippets.

@milankragujevic
Created August 14, 2025 08:14
Show Gist options
  • Save milankragujevic/48b3605f6118826ffdcd114c1ab20102 to your computer and use it in GitHub Desktop.
Save milankragujevic/48b3605f6118826ffdcd114c1ab20102 to your computer and use it in GitHub Desktop.
Jedan nesveti regex koji validira srpske (fiksne i mobilne) brojeve telefona
<?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