I have a string which is a sequence of html paragraphs, I want to remove (using String’s method replaceAll) paragraphs which contain the word “UPDATE”, usually they are in this form:
<p><a href="blabla">(UPDATE)<a></p>
but there could be other, as for example some strong section.
As it’s almost impossible that a normal paragraph contain the exact word “UPDATE” I’d like just to find a regex which can find a paragraph which contains this word and remove it with
replaceAll("regex","");
can you help me to find “regex” part?I’m not good at all with regex…
I think this is what you’re looking for. You need to use the .*? instead of .* because that forces the search to be lazy instead of greedy.