I have not a lot of experience with regular expression and have an issue where I need to replace all instances of >
and <
with <
and >
but to leave the HTML tags in tack.
For example:
String string =" <p class=\"anotherClass\"> Here is some text the value is for H<sub>2</sub>O is > 1 and < 100 <p>";
//need to be converted to:
<p class=\"anotherClass\"> Here is some text the value is for H<sub>2</sub>O is > 1 and < 100 <p>";
I have tried some look and ahead and behind expressions but I can not seem to get any of them to work. For example:
String string =" <p class=\"anotherClass\"> Here is some text the value is for H<sub>2</sub>) is > 1 and < 100 <p>";
String reg1="<(?=[^>\\/]*<\\/)";
Pattern p1 = Pattern.compile(reg1);
test = p1.matcher(string).replaceAll("<");
Does not seem to have any effect.
I wondered if anyone else had come across this before or if anyone can give me any guidance?