I attempted to create a Regex that matches Opening HTML Tags.
<\w+((\s+\w+(\s*=\s*(?:\".*?\"|'.*?'|[^'\">\s]+))?)+\s*|\s*)>
Is what I have come up with. It works great in RegexPal.com http://gyazo.com/cef34f653c4a3483a31394330455c0cf But as soon as I try to use it on some text in JS (both Chrome and Node) this happens: http://gyazo.com/0c938ee289c1632f3f576aaccda1f81e
Rules is defined like that:
var Rules = [
new RegExp("<\w+((\s+\w+(\s*=\s*(?:\".*?\"|'.*?'|[^'\">\s]+))?)+\s*|\s*)/>"),
new RegExp("<\w+((\s+\w+(\s*=\s*(?:\".*?\"|'.*?'|[^'\">\s]+))?)+\s*|\s*)>"),
new RegExp("</\w+((\s+\w+(\s*=\s*(?:\".*?\"|'.*?'|[^'\">\s]+))?)+\s*|\s*)>")
];
and Content is defined like that:
var Content = "<!DOCTYPE HTML><html><head><title>derp</title></head><body><div class=\"derp\"><!--this is formatted terribly -->derp<br /></div></body></html>";