Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

Re: Perl regex

by Prof Vince (Friar)
on Sep 06, 2007 at 10:38 UTC ( #637377=note: print w/ replies, xml ) Need Help??


in reply to Perl regex

You could use Text::Balanced for that :

use Text::Balanced qw/gen_extract_tagged/; my $text = q{hereiam[[one[[foo]]bar]]baz[[two]][[three]]wwhat}; my $parser = gen_extract_tagged "\Q[[", "\Q]]", qr/.*?(?<!\[\[)(?=\[\[)/, { bad => [ "\Q[[" ] }; while (($extracted, $remainder) = $parser->($text) and $remainder ne $text) { print "$extracted\n"; $text = $remainder; }


Comment on Re: Perl regex
Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://637377]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others surveying the Monastery: (7)
As of 2015-07-04 03:32 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (57 votes), past polls