This one is a real head scratcher for me...
var matches = Regex.Matches("<p>test something<script language=\"javascript\">alert('hello');</script> and here's <b>bold</b> and <i>italic</i> and <a href=\"http://popw.com/\">link</a>.</p>", "</?(?!p|a|b|i)\b[^>]*>");
The Regex is supposed to capture any HTML tag (open or close) that's not p, a, b, or i. I've plugged the input string and regex into countless testing pages, and every one of them return the script tag (open and close) as matches. But it absolutely doesn't work in the code. The matches variable has a count of 0.
Am I missing something incredibly obvious?
You forgot to escape the backslash in the pattern string.
"</?(?!p|a|b|i)\\b[^>]*>"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With