I am trying to find a substring in a string. Then remove already present <b>
tags from the original string & add <b>
tag before & after the substring existence in the original string.
I need help with this, what I've tried so far is below
String originalString = "<b>ProLiantDL380CltrG2</b> HWSupp";
String subString = "ProLia"
if (StringUtils.containsIgnoreCase(originalString, subString)) {
System.out.println("substring matched true");
System.out.println("before : " + originalString);
//Need to remove the <b> & </b> from the originalString
originalString.replace("<b>", ""); // doesn't work
originalString.replace("</b>", "");
System.out.println("after : " + originalString);
//after remove the <b> tags I need to add those tags at the start &
end index of the substring existence in the original string
like "<b>ProLia</b>ntDL380CltrG2 HWSupp"
}
}
Output : not as expected
product matched true
before : <b>ProLiantDL380CltrG2</b> HWSupp
after : <b>ProLiantDL380CltrG2</b> HWSupp