Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

Re: extract a substring between two emements

by AnomalousMonk (Monsignor)
on Oct 10, 2011 at 14:32 UTC ( #930650=note: print w/ replies, xml ) Need Help??


in reply to extract a substring between two emements

>perl -wMstrict -le "my $line = 'Hello hello START this is comment END ' . 'START this is still comment END ' . 'START this should still be comment END ' . 'this is fixed' ; ;; my $START = qr{ START \s* \K }xms; my $END = qr{ (?= \s* END) }xms; my $not_end = qr{ (?! $END) . }xms; ;; my ($extract) = $line =~ m{ $START $not_end* should $not_end* $END }xmsg; print qq{[[$line]]}; print qq{'$extract'}; " [[Hello hello START this is comment END START this is still comment END START this should still be comment END this is fixed]] 'this should still be comment'


Comment on Re: extract a substring between two emements
Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others surveying the Monastery: (9)
As of 2014-08-22 22:18 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The best computer themed movie is:











    Results (168 votes), past polls