Skip to content

Instantly share code, notes, and snippets.

@atbradley
Created April 28, 2011 14:22
Show Gist options
  • Save atbradley/946440 to your computer and use it in GitHub Desktop.
Save atbradley/946440 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