', $highlightedText);
$highlightedText = str_replace('[/b]', '', $highlightedText);
}
?>
Test regular expressions
preg_match_all($pattern, $subject, $matches, PREG_SET_ORDER)
$escapedRegexp matched!\n";
echo "
Here's what was matched searching the text you entered:
\n";
$y = 0;
echo '';
foreach ($results as $loop_result) {
$x = 0;
foreach ($loop_result as $loop_result2) {
if ($x != 0) {
/* Indent subpatterns. */
echo "
";
}
printf('$matches[%s][%s]: ', $y, $x);// show variable name
if (!$loop_result2) {
echo 'Empty';
} else {
echo '' . htmlentities($loop_result2) . '';
}
if ($x != 0) {
echo "
";
} else {
echo "
";
}
$x++;
}
$y++;
}
echo '
';
} else { // no match
echo "regexp $escapedRegexp doesn't return any results\n";
}
?>
Searched text with matches highlighted
';
echo $highlightedText;
echo '
';
}
?>
Example regular expressions:
{<!--(?:.|\s)*?-->} -- Shows comments in html
- { open delimiter
- <!-- search for opening comment tag
- (?:.|\s)* any number of characters or white space
- ? non-greedy
- --> search for closing comment tag
- } close delimiter
{<style type(?:.|\s)*?</style>} -- Shows styles
Notes:
- The results page shows the individual matches and subpattern matches, and the original text with the matches highlighted.
- Might not be able to search for html entities like "&" because of the converting for display and textareas (the search pattern (regexp) and non-url subjects are processed by unhtmlentities)