Reply to Problem with preg_match with capturing and back-reference

Your name:

Reply:


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

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация