Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

Answer: How would I find a piece of html from a sourcefile.html?

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

Q&A > regular expressions > How would I find a piece of html from a sourcefile.html? contributed by athomason

Comments make HTML extraction even more difficult than it usually is. However, if you're dealing with fairly standard HTML you could use
$page =~ /<!--\w+(.*)\w*-->;/; $commented = $1;
This will grab the string inside the comment; add appropriate qualifiers to the regexp as necessary (or use another on $commented) if you only want to pick certain stuff out.

Comment on Answer: How would I find a piece of html from a sourcefile.html?
Download Code
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 musing on the Monastery: (16)
As of 2015-07-31 16:55 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 (279 votes), past polls