What would be the Java equivalent to :
def filt_out(s):
return re.sub('<a href="(.*)">', '', s.replace('<br/>', '\n').replace('"', '\"').replace('</a>', ''))
What would be the Java equivalent to :
def filt_out(s):
return re.sub('<a href="(.*)">', '', s.replace('<br/>', '\n').replace('"', '\"').replace('</a>', ''))
public static String filtOut(String s) {
return s.replaceAll("<a href=\"(.*)\">", "").replaceAll("<br/>", "\n").replaceAll(""", "\"").replaceAll("</a>", "");
}
Though, such code style is not recommended as well as the approach in general. Usually, you should use special HTML parsers for processing HTML. Regular expressions are too limited for that task.
You can look the following questions on html parsers: