|
Posted by pt on 08/18/06 16:23
I'm trying to detect and extract a quoted portion of a string. The
quote chars may be the usual quote, the "single" quote (apostrophe) or
the back-tick quote. For example:
$vl = "My O'Name";
if (preg_match ( '/(["\'\`])([^\\1]*)/' ) , $vl , $x ) { // found it }
The first parenthesized expression will capture the leading quote
(whatever it is). The second *SHOULD* capture everything up to, but
not including, the matching trailing quote. What I get is $x[1]
contains the quote (as expected), but $x[2] is everything up to AND
INCLUDING the trailing quote.
This is PHP 5.1.2 with PCRE 6.2 01-Aug-2005
Navigation:
[Reply to this message]
|