java - need to clean malformed tags using regular expression -
Searching for the proper regular expression for the following situations: I have to clear some tags for free Flowing text For example, I have two important tags within the text: & lt; 2004: 04: 12 & gt; and & lt; Person's name & gt; Unfortunately, some tags include "& lt;" Or ">" delimiter For example, some are as follows: 1) I tried to use the following for position 1: string regex = "& lt; \\ d {4} - \\ D {2} - \\ d {2} \\ w * {2} [^ & gt;] "; String output = content.replaceAll (regex, "$ 0>"); All examples of "2004: 04: 12" were found and the result was "& lt; 2004: 04: 12>". However, I need to eliminate the location before the finished tag. Of course this is the best way. any suggestion. Thanks In fact, you have a negative look- forward, like this: string regex = "& lt; \\ d {4} - \\ d {2} - \\ d {2} (?! & Gt;)"; String output...