Remove HTML tags from a String in Dart

前端 未结 5 1795
傲寒
傲寒 2020-12-17 09:00

I’ve been trying to achieve this for a while, I have a string which contains a lot of HTML tags in it which is in some encoded form Like & lt; and & gt; (without th

5条回答
  •  眼角桃花
    2020-12-17 09:36

    You can simply use RegExp without 3rd Lib

    String removeAllHtmlTags(String htmlText) {
        RegExp exp = RegExp(
          r"<[^>]*>",
          multiLine: true,
          caseSensitive: true
        );
    
        return htmlText.replaceAll(exp, '');
      }
    

提交回复
热议问题