note 26009 deleted from function.preg-match by sniper
| From: | sniper@php.net | Date: | Tue, 30 Sep 2003 12:14:00 +0000 |
| Subject: | note 26009 deleted from function.preg-match by sniper | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-57397@lists.php.net to get a copy of this message | ||
Note Submitter: vectorpup@hotmail.com
----
function preg_xmatch($match, $string, &$regs) {
//removes comments, whitespace, newlines and carraige returns from a PCRE expression
// useful for debugging PCRE 'programs' or very complex match routines
// remember to ESCAPE whitespace (\s) if needed
// unsuitable for matches which actually involve newlines or carraige returns
// if you wish to do so, it's better to just match them via the dotall (s)
// modifier
// if you wish to use comments AND match newlines, use the pcre "x" modifier
// once done, it is best to use the below matchstring to clean your match up
// and use a standard match for the finished project, as this version
// DOUBLES the runtime of any standard match.
$match=preg_replace("/(\r|\n|\s|\(\?\#.*\))/", "", $match);
return preg_match($match, $string, $regs);
}