Let\'s say i have a html fragment like this:
foo bar foobar baz <
foo bar foobar baz
Using Regex: -
String str = " foo bar foobar baz "; str = str.replaceAll("<[^>]*>", ""); System.out.println(str);
OUTPUT: -
Using Jsoup: -
Document doc = Jsoup.parse(str); String text = doc.text();