Skip to content

Instantly share code, notes, and snippets.

@daGrevis
Created June 7, 2012 12:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save daGrevis/2888469 to your computer and use it in GitHub Desktop.
Save daGrevis/2888469 to your computer and use it in GitHub Desktop.
regexilioucieus
<?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