public static string MakeWebSafe(this string x) {
const string RegexRemove = @"(<\s*script[^>]*>)|(<\s*/\s*script[^>]*>)";
return Regex.Replace(x, RegexRemove, string.Empty, RegexOptions.IgnoreCase);
}
Is there any reason this implementation isn't good enough. Can you break it? Is there anything I haven't considered? If you use or have used something different, what are its advantages?
I'm aware this leaves the body of the script in the text, but that's okay for this project.
UPDATE
Don't do the above! I went with this in the end: HTML Agility Pack strip tags NOT IN whitelist.
<script>elements from a string.