How to clear HTML tags from String

Asked 1 years ago, Updated 1 years ago, 79 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.