note 95430 added to function.preg-quote

From: Date: Sun, 03 Jan 2010 04:49:11 +0000
Subject: note 95430 added to function.preg-quote
Groups: php.notes 
Request: Send a blank email to php-notes+get-164555@lists.php.net to get a copy of this message
preg_quote wasn't escaping the hyphen. According to a previous comment, this is a bug that has been fixed as of 5.3. Here is a function that fixes it: <?php function regex_quote ($str, $delim='/') { $quoted = preg_quote($str, $delim); if ( version_compare(PHP_VERSION, '5.3.0', '<') ) $quoted = str_replace('-', '\\-', $quoted); return $quoted; } ?> ---- Server IP: 69.147.83.197 Probable Submitter: 71.238.254.92 ---- Manual Page -- http://www.php.net/manual/en/function.preg-quote.php Edit -- https://master.php.net/note/edit/95430 Del: integrated -- https://master.php.net/note/delete/95430/integrated Del: useless -- https://master.php.net/note/delete/95430/useless Del: bad code -- https://master.php.net/note/delete/95430/bad+code Del: spam -- https://master.php.net/note/delete/95430/spam Del: non-english -- https://master.php.net/note/delete/95430/non-english Del: in docs -- https://master.php.net/note/delete/95430/in+docs Del: other reasons-- https://master.php.net/note/delete/95430 Reject -- https://master.php.net/note/reject/95430 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#164555) next »