Skip to content

Instantly share code, notes, and snippets.

@jstortz
Forked from atbradley/stripTags.groovy
Created March 16, 2018 14:26
Show Gist options
  • Save jstortz/ae11d77b188bb4f3a52b6b87693f8a43 to your computer and use it in GitHub Desktop.
Save jstortz/ae11d77b188bb4f3a52b6b87693f8a43 to your computer and use it in GitHub Desktop.
Very simplistically remove HTML tags from strings.
public static String stripTags(String input) {
return input.replaceAll("\\<.*?>","");
}
// In Groovy we can add a stripTags method to the String class:
String.metaClass.stripTags() {
delegate.replaceAll("<(.|\n)*?>", '')
}
String.prototype.stripTags = function() { return this.replace(/<.+?>/g, ''); };
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment