0

Using the RegExp().exec() this method works well in chrome and edge but not working in IE11 and its lower version.

Eg:

regExp = "^(\d\d?)(\/)(\d\d?)(\/)(\d{4})$"
value = "1/1/2018"

match = new RegExp(regExp).exec(value);  //returns null value in ie11

The above RegExp is converted into /^(\d\d?)(/)(\d\d?)(/)(\d{4})$/ as result of new RegExp(regExp) but still getting null value. please check the image below click here

  • And this works just fine in IE: `console.log(/^(\d\d?)(\/)(\d\d?)(\/)(\d{4})$/.exec("1/1/2018"))` – mplungjan Jun 08 '18 at 09:10
  • Because you failed to define backslashes in the string literal. `console.log(new RegExp(regExp).source)` shows `^(dd?)(\/)(dd?)(\/)(d{4})$`. Use a regex literal, `/^(\d\d?)(\/)(\d\d?)(\/)(\d{4})$/`. – Wiktor Stribiżew Jun 08 '18 at 09:10
  • The code you’ve put in the question should produce `null` in every browser. Did you maybe run something slightly different in Chrome and Edge? – Ry- Jun 08 '18 at 09:10
  • Just saw this exactly the same question, yesterday ..? Nope, it was [2 days ago](https://stackoverflow.com/questions/50699472/does-ie11-have-support-for-regexp). – Teemu Jun 08 '18 at 09:14
  • @Teemu, please share that link if possible. – vinoth-kumar-s Jun 08 '18 at 09:21
  • ?? It is shared in my comment above. – Teemu Jun 08 '18 at 09:22

0 Answers0