I’m trying to use regex to match a string that starts with a <p> tag and has some specific content. Then, I want to replace everything from that specific paragraph tag to the end of the page.
I’ve tried using the expression <p.*?some content.*</html>, but it grabs the first <p> tag it sees, then follows through all the way to the end. I want it to only recognize the paragraph tag immediately preceding the content, allowing for other content and tags between the paragraph tag and the content.
How can I get to some specific content with the regex, then backtrack to the first paragraph tag it sees before the content, and then select everything from there to the end?
If it helps, I’m using EditPad Pro’s “Search & Replace” function (although this could apply to anything that uses regex).
For simple input use regex
<p[^<]*some content.*<\/html>but safer would be to use regex
<p(?:[^<]*|<(?!p\b))*some content.*<\/html>