note 26009 added to function.preg-match

From: Date: Tue, 15 Oct 2002 07:05:30 +0000
Subject: note 26009 added to function.preg-match
Groups: php.notes 
Request: Send a blank email to php-notes+get-38089@lists.php.net to get a copy of this message
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); } -- http://www.php.net/manual/en/function.preg-match.php http://master.php.net/manage/user-notes.php?action=edit+26009 http://master.php.net/manage/user-notes.php?action=delete+26009 http://master.php.net/manage/user-notes.php?action=reject+26009

« previous php.notes (#38089) next »