Re: find quoted string within a string (more of a regex question, though ..)
| From: | Robin Vickery | Date: | Fri, 10 Sep 2004 13:41:56 +0000 |
| Subject: | Re: find quoted string within a string (more of a regex question, though ..) | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-196303@lists.php.net to get a copy of this message | ||
On Fri, 10 Sep 2004 11:43:54 +0200, Wouter van Vliet
<wouter.van.vliet@gmail.com> wrote:
>
> For my own reasons (can explain, would take long, won't till sbody
> asks) I want to match a quoted string within a string. That is somehow
> kind of easy, I know ... if it weren't for the slashing of quotes.
The standard perl regexp for matching double-quote delimited strings is this:
/"([^"\\]|\\.)*"/
which copes nicely with escaped characters. You'll probably need to
double up the backslashes in php.
$regex = '/"([^"\\\\]|\\\\.)*"/';
-robin