I am parsing a poorly structured rss feed, and some of the data that is being returned has <p>at in it. How can I replace all instance of <p>at with an empty space, using java?
I’m familiar with the .replace method for the String class, but I’m not sure how the regex expression would look. I tried inputString.replace("<p>at", "") but that didn’t work.
Try this:
Be aware that the
replace()method does not modify theStringin-place (as is the case with all methods in theStringclass, because it’s immutable), instead it returns a newStringwith the modifications – and you need to save the returned string somewhere.Also, the above version of
replace()doesn’t receive a regular expression as an argument, just the string to be replaced and its replacement.