I'm using following regex pattern to check a string contains html.
string input = "<a href=\"www.google.com\">test</a>";
const string pattern = "</?\\w+((\\s+\\w+(\\s*=\\s*(?:\".*?\"|'.*?'|[^'\">\\s]+))?)+\\s*|\\s*)/?>";
Regex reg = new Regex(pattern);
var matches = reg.Matches(input);
It works fine but if string text value contains < or > characters it returns true too, but it shouldn't. For example the following is not considered an HTML tag in our system.
string input = "<test>";
How can I add to this pattern an AND for </
and />
Thanks