Javascript Regex Not Detecting
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
Solution 1:
The problem is if you want to use RegExp()
you need to double up the \
.
new RegExp("<\\w+((\\s+...
It would be better to drop the RegExp and just use /regExp/
varRules= [
/<\w+((\s+\w+(\s*=\s*(?:\".*?\"|'.*?'|[^'\">\s]+))?)+\s*|\s*)/>/,
/<\w+((\s+\w+(\s*=\s*(?:\".*?\"|'.*?'|[^'\">\s]+))?)+\s*|\s*)>"/,
/</\w+((\s+\w+(\s*=\s*(?:\".*?\"|'.*?'|[^'\">\s]+))?)+\s*|\s*)>/
];
Post a Comment for "Javascript Regex Not Detecting"