Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

Answer: Double quotes within double quotes

( #6884=categorized answer: print w/ replies, xml ) Need Help??

Q&A > regular expressions > How can I find nested delimiters? - Answer contributed by btrott

my $query = qq("SOME QUERY WITH "" (DOUBLE QUOTES)" YEEHA); if ($query =~ /"(.*)"(.*)/) { my $inside = $1; my $outside = $2; print $inside, "\n", $outside, "\n"; }
This works because the regex is greedy.

But I'm not sure if this is really what you want-- was that query merely an example, or is that really what all your queries look like?

If it's the former, and you're trying to do something more complicated than what you describe above--for example, match balanced text--you might take a look at perlfaq6, Can I use Perl regular expressions to match balanced text?.

Also, see Text::Balanced on CPAN. -- Ed.

Log In?
Username:
Password:

What's my password?
Create A New User
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others imbibing at the Monastery: (12)
As of 2016-06-30 14:02 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    My preferred method of making French fries (chips) is in a ...











    Results (396 votes). Check out past polls.