[removed] what's the point of RegExp.compile()?

后端 未结 4 1530
刺人心
刺人心 2020-12-05 09:13

I\'ve got a situation where I want to get a regexp from the user and run it against a few thousand input strings. In the manual I found that the RegExp object h

4条回答
  •  醉酒成梦
    2020-12-05 09:51

    As far as i can tell all RegExp.compile does is replace the underlying regular expression of a RegExp object. I think compile may have had value in the past, but all modern JS engines "compile" the regex on first call and cache that "compiled" version.

提交回复
热议问题