Created
June 7, 2012 12:13
-
-
Save daGrevis/2888469 to your computer and use it in GitHub Desktop.
regexilioucieus
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 | |
function symbolCheck($input) { | |
return preg_match('/^[\pL0-9\:\/\.\_\-]/uD', $input); | |
} | |
$cases = array( | |
'abc:', | |
'abc123/_', | |
'āč-ē', | |
'āčē123', | |
'*', // should fail | |
'++++', // should fail | |
); | |
foreach ($cases as $case) { | |
if (symbolCheck($case)) { | |
echo $case.' : true<br />'; | |
} else { | |
echo $case.' : false<br />'; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment