IE8 vs IE9 JavaScript regular expressions changed a little bit their behaviour

Well, may be I am using regular expressions wrong in the browser, but I had a strange problem on a customersite today, that the JavaScriptcode ran into endless loops. Having analysed the problem it turned out, that the JavaScriptengine changed from IE8 to IE9. When I switched back to IE9 compat view, everything worked fine.

So, what is wong? The result of an exec call on a regular expression (in IE8) returned on successful match someting like lastIndex, which pointed right after the matched phrase in the string. With IE9, this property is gone. So, I have to use something like the index property of the match and add the length of my match.

According to this, lastIndex should be there even in IE9. But my debugger states something else…

One Response to IE8 vs IE9 JavaScript regular expressions changed a little bit their behaviour

Leave a Reply