Wednesday, January 14, 2009

javascript error invalid quantifier in string.match regular expression

Yesterday I was trying to write some little regular expression to extract the title of a page from it's html and got the below error -

invalid quantifier *)\<\/title

The actual code that generated this error was the following -


The code works just as expected and extracts the page titles but it seems javascript doesn't support back references or something and that results in the "invalid quantifier" error in both Firefox and Internet Explorer.

Anyhow, I replaced it with a substring (looking for <title and <\/title) and that works fine too. But if you know how to write a regular expression that does it without throwing this error, please share....

No comments:

Post a Comment