Type forced error in IE8 RegExp.exec ()?

I do not know if this problem is a problem in IE8, but I can not find any information about this.

// The regex can vary but has to have a non-matching group defined: var re = /^(\s)?[\d]+$/i; // We call it with a string... re.exec("2"); // We call it with a number... re.exec(2); 

Firefox and Chrome (I can’t try it in Opera right now) have no problems with calls. But on IE8, the second call fails with "Object does not support this property or method."

Is this a known bug or something else?

+4
source share
2 answers

Since exec accepts the string, I would make sure you pass the string. Skipping a number, I would say that you are trying to rely on the gray areas in which browsers implement javascript.

+1
source

I saw the same problems in an Ext JS 4 application. Many things failed because Ext JS seems to sometimes skip numbers in the exec () method. This issue turned out to be a third-party SyntaxHighlighter library. Removing this parameter led to the default behavior of IE8 and re.exec (2); have worked.

I would suggest reducing the external JS that you included in your application until you find the culprit.

+1
source

Source: https://habr.com/ru/post/1345696/


All Articles