0

My problem: I need to delete and replace complex parts from a long HTML string.

Example:

// <div>
text = text.replaceAll("<div>", "");

This is not a problem. But div can also be <div class="anything">. How can I detect and replace such passages? So if a part that is between < and > is unknown?

  • 1
    You cannot parse XML using a regex, because what if the text contained inside an attribute value also contains a <> ? – Vinz243 May 11 '22 at 11:37
  • Try using regex such as `text = text.replace(//gi, "");` – Hao Wu May 11 '22 at 11:37
  • 1
    This could be an XY problem, could you explain in more detail what your trying to achieve. – Keith May 11 '22 at 11:38
  • 1
    https://stackoverflow.com/questions/1732348/regex-match-open-tags-except-xhtml-self-contained-tags/1732454#1732454 – zer00ne May 11 '22 at 11:42

0 Answers0