Skip to content

Instantly share code, notes, and snippets.

@ussjoin
Created August 18, 2009 21:00
Show Gist options
  • Save ussjoin/169962 to your computer and use it in GitHub Desktop.
Save ussjoin/169962 to your computer and use it in GitHub Desktop.
import java.util.regex.*;
public class Test
{
public static void main(String[] args)
{
String haystack = "<script>Bad</SCRIPT>Good";
String stripHTMLPattern = "<script>.+?</script>";
Pattern pattern = Pattern.compile(stripHTMLPattern, Pattern.CASE_INSENSITIVE);
Matcher matcher = pattern.matcher(haystack);
String stripped = matcher.replaceAll(" ");
System.out.println(stripped);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment