I recently wrote a script to check which of multiple regular expressions an input matches.
It doesn't work. I get the errors:
The last line repeats infinitely until I stop the page loading or my browser crashes.Warning: preg_match() [function.preg-match]: Unknown modifier '{' in /home/seangill/public_html/AskMingSushi.php on line 24
Warning: preg_match() [function.preg-match]: Unknown modifier '{' in /home/seangill/public_html/AskMingSushi.php on line 24
Warning: preg_match() [function.preg-match]: Unknown modifier '{' in /home/seangill/public_html/AskMingSushi.php on line 24
Warning: preg_match() [function.preg-match]: Unknown modifier '{' in /home/seangill/public_html/AskMingSushi.php on line 24
Warning: preg_match() [function.preg-match]: Unknown modifier '{' in /home/seangill/public_html/AskMingSushi.php on line 24
Warning: preg_match() [function.preg-match]: Unknown modifier '{' in /home/seangill/public_html/AskMingSushi.php on line 24
Warning: preg_match() [function.preg-match]: Empty regular expression in /home/seangill/public_html/AskMingSushi.php on line 24
I normally program in JavaScript, so it's quite likely that I did something that doesn't work in PHP. Here's the script:
PHP Code:$inputted = $_POST['input'];
$functions = array('big','long','array','removed');
$names = array('big','long','array','removed');
$expressions = array(
"Big long regular expression removed", //WoofNet, plain and simple
'Big long regular expression removed', //Yikes! This is for translation, believe it or not.
"Big long regular expression removed", //Adopt a pet near you today!
"Big long regular expression removed", //Who wants to adopt a pet?
"Big long regular expression removed", //What's my local weather right now?
);
$matched = array(0,0,0,0,0,0);
$numcycled = 0;
while (numcycled < count($expressions)):
/*line 24*/ if (preg_match($expressions[$numcycled], $inputted) == 1) {
$matched[$numcycled] = 1;
echo 'Matched ' . $functions[$numcycled] . ' (' . $names[$numcycled] . ').<br/>';
}
$numcycled++;
endwhile;



Reply With Quote

Bookmarks