stripHtml property
Strips all HTML code from String
.
Example
String html = '<script>Hacky hacky.</script> <p>Here is some text. <span class="bold">This is bold. </span></p>';
String stripped = foo.stripHtml; // returns 'Hacky hacky. Here is some text. This is bold.';
Implementation
String get stripHtml {
if (isBlank) {
return blankIfNull;
}
// ignore: unnecessary_raw_strings
var regex = RegExp(r'<[^>]*>');
return replaceAll(regex, '');
}