stripHtml property

String? stripHtml

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 (this.isBlank) {
    return this;
  }

  // ignore: unnecessary_raw_strings
  var regex = RegExp(r'<[^>]*>');
  return this!.replaceAll(regex, '');
}