"Jonathan Weber" schreef:

> <a name="w12234"> </a> <h2>A Title</h2>
>
> I'm using a regular expression to find these and capture the name
> attribute ("w12234" in the example) and the contents of the h2 tag ("A
> Title").
>
> $_ =~ /<a name="(w\d+)">\s*<\/a>\s*<h2>(____+)<\/h2>/
>
> That's my regex, except I'm having trouble with the _____ part. No
> matter what I seem to try, it won't match incidences where there's a
> newline somewhere in the string. I tried all manner of things,
> including [.\n], which if I understand correctly should match
> *everything*.

Not "[.\n]" (because that contains a literal dot), but "(?:.|\n)".
Or do a "s/\n/ /g" first.

But you don't need all that, see `perldoc perlre` about the s-modifier.

And much better: use a proper HTML parser, see CPAN.

-- 
Affijn, Ruud

"Gewoon is een tijger."



-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to