Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

Re: Regex to match first html tag previous to text

by erroneousBollock (Curate)
on Nov 29, 2007 at 02:18 UTC ( #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
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
Node Status?
node history
Node Type: note [id://653746]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (11)
As of 2015-07-02 06:24 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 (30 votes), past polls