note 38519 deleted from function.preg-quote by felipe
| From: | felipe@php.net | Date: | Mon, 10 Dec 2007 02:21:18 +0000 |
| Subject: | note 38519 deleted from function.preg-quote by felipe | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-133104@lists.php.net to get a copy of this message | ||
Note Submitter: mina86 at tlen dot pl
----
Re: adrian holovaty
You must also escape '#' character. Next thing is that there is more then one whitespace
character (a space).. Also IMO the name preg_quote_white() won't tell what the new function
does so we could rename it. And finally, we should also add $delimiter:
<?php
function preg_xquote($a, $delimiter = null) {
if ($delimiter) {
return preg_replace('/[\s#]/', '\\\0', preg_quote($a,
substr("$delimiter", 0, 1)));
} else {
return preg_replace('/[\s#]/', '\\\0', preg_quote($a));
}
}
?>