Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

Re: pattern matching

by JediWizard (Deacon)
on Jul 18, 2005 at 17:18 UTC ( [id://475823]=note: print w/replies, xml ) Need Help??


in reply to pattern matching

First: It is really not recomended to use regex to parse htlm (tends to turn into a nightmare).

Second: You need to use the s modifier on your regex in order to make . match the newline character.

Third: using .+ is greedy, and will match from the first <!-- Start_of_revision--> to the last <!-- End_of_revision--> (which I am sure is not what you want).

Forth: The code below is untested

@revision_array=(); my $start = qr/<!-- Start_of_revision-->/; my $end = qr/<!-- Start_of_revision-->/; if (m/$start((?:(?!$end).)+)$end/msg) { push (@revision_array, $1); }

Update: And to get all of them, that if should be a while


They say that time changes things, but you actually have to change them yourself.

—Andy Warhol

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others avoiding work at the Monastery: (6)
As of 2024-04-24 16:47 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found