I have been told by a number of people to use xpath instead of regex for some of my regex searches. What advantages does xpath provide over regex? I can't find a webpage that says that. Been through over 10 pages of search so far.

I have been told by a number of people to use xpath instead of regex for some of my regex searches.

What are you searching?

Some notes about XML/webpages here is regex not the right tool.
If you are parsing(searching) XML/html you should use beautifulsoup / lxml(has XPath built in) that is designed exactly for this purpose.

Why is regex bad for xml/html read this very good answer.
http://stackoverflow.com/questions/1732348/regex-match-open-tags-except-xhtml-self-contained-tags

Edited 5 Years Ago by snippsat: n/a

Okay well I will be searching HTML documents and php generated pages that outputs either straight text or mimics XML. I have xml parsing down with lxml. So I should switch to all lxml and xpath?

Like snippsat said. If you need to parse html/php page you will need beautifulsoup or the hard way using regex.
The choice is yours. :)

This question has already been answered. Start a new discussion instead.