You don't need javascript to parse HTML. Just use an HTML parser. They are very fast. HTML isn't a regular language, so you can't parse it with regular expressions.
Obligatory: https://stackoverflow.com/questions/1732348/regex-match-open...
Obligatory: https://stackoverflow.com/questions/1732348/regex-match-open...