I here all the time how much faster perl regex is than posix regex. So, I thought I'd test it instead of just taking people's word for it.
OK, here's the script I ran to compare the performance of these two regexes:
<?php
function mt(){
$tmp = split(" ",microtime());
return $tmp[0]+$tmp[1];
}
$string = "Bob Jones_University*";
$tp[] = mt();
for ($i=0;$i<100000;$i++){
$a = ereg('^[ _[:alnum:]]+$', $string);
}
$tp[] = mt();
for ($i=0;$i<100000;$i++){
$a = preg_match("/^[\w ]+$/", $string);
}
$tp[] = mt();
print $tp[1]-$tp[0];
print "\n";
print $tp[2]-$tp[1];
print "\n";
?>
And the output I got was:
1.3014370203018 <- regex
1.0914809703827 <- perl regex
Let's face it, the performance difference isn't that great. Maybe if you're importing 1,000,000 rows you might see a 3 second difference processing the rows with pcregex versus posixregex.
In what way are perl regex generally more powerful? Just wondering, I've never spent a lot of time working on them because I consider the syntax to be confusing and it reminds me way too much of my old days wrestling with perl regex when I coded in perl.