Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
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 studying the Monastery: (17)
As of 2014-12-18 13:46 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (52 votes), past polls