Skip to content

Instantly share code, notes, and snippets.

@davestevens
Created June 9, 2011 09:39
Show Gist options
  • Save davestevens/1016427 to your computer and use it in GitHub Desktop.
Save davestevens/1016427 to your computer and use it in GitHub Desktop.
Example of preg_match
<?php
/* test regex */
$input[] = 'admin/';
$input[] = 'mens-books';
$input[] = 'admin/foo';
$input[] = 'foo/bar';
$input[] = 'min';
$input[] = 'admin';
$regex = '/^(?!admin\/)/';
foreach ($input as $in) {
echo $in . ' - ';
if(preg_match($regex, $in)) {
echo 'Match';
}
else {
echo 'No Match';
}
echo "\n";
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment