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

Re: Regex to match first html tag previous to text

by erroneousBollock (Curate)
on Nov 29, 2007 at 02:18 UTC ( [id://653746]=note: print w/replies, xml ) Need Help??


in reply to Regex to match first html tag previous to text

I'd use HTML::TreeBuilder::XPath to find the nodes in question, then alter the values in the "DOM" and use methods from HTML::Tree to write the document back out.

Regular expressions are a very fragile solution to the "how do I parse HTML" problem.

-David

  • Comment on Re: Regex to match first html tag previous to text

Replies are listed 'Best First'.
Re^2: Regex to match first html tag previous to text
by Greebo (Initiate) on Nov 30, 2007 at 17:09 UTC
    Thanks for the reply - as it happened (as it so often happens whenever I post asking for help with something) I stumbled upon a regex solution to this problem by accident, but given the majority of people saying regex is not the way to go here, I will definitely look into this and the various other options people suggested

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others studying the Monastery: (3)
As of 2024-04-26 06:16 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found