How to clear HTML tags from String

Asked 2 years ago, Updated 2 years ago, 91 views

Is there a good way to erase HTML tags in Java String? replaceAll ("\<.*?>","") like this. This works well, but I can't change this and erase it when it's a sentence like "<Content>" instead of an HTML tag.

html java parsing

2022-09-22 14:24

1 Answers

Try Jsoup

public static String html2text(String html) {
    return Jsoup.parse(html).text();
}


2022-09-22 14:24

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.