本文介绍了V8是否自动缓存编译的正则表达式?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 所以我知道在Javascript实例化一个正则表达式会导致它自动编译,如果该正则表达式存储在一个变量中,它将被重用而无需重新编译。示例: var re = / [Ff] oo | [Bb] ar /; Foo。匹配(重新); // [Foo] Baz。匹配(重新); // null 然而,是重新编译重复的正则表达式还是智能地执行V8(Chrome / Node.js)重用它们(就像PHP用preg_ *函数)? function isFooBar(str){ return str .match(/ [FF] OO | [BB] AR /); } isFooBar(Foo); // [Foo] isFooBar(Baz); // null 所以为了澄清,我知道第一个例子是一个正则表达式编译的结果。但是第二个例子怎么样?解决方案好吧,让我们来看看。 // http://stackoverflow.com/questions/3466850/complex-password-regular-expressionfunction isFooBar(str){return str.match(/ ^(:(= * [AZ])(?:?????(= * [AZ])(= * [\d\W])|(= * \W)(= * \d))|????(= * \W)(= * [AZ])(= * \d)){8}(。? :(= * [AZ]。)(?:???(= * [AZ])(= * [\d\W])|(= * \W)(=?。 * \d))|(= * \W)(= * [AZ])(= * \d)){8}(?:(= * [AZ????。 ])(?:?(= * [AZ])(?= * [\d\W])|(?= * \W)(?= * \d))|( ?= * \W)(= * [AZ])(= * \d)){8}(?:?。?(= * [AZ])(?:?(= * [AZ])(= * [\d\W])|?(= * \W)(= * \d))|??(= * \W)?。 (?= * [AZ]。)(= * \d?)){8}。(?:?(= * [AZ])(?:(= * [AZ])(?? = * [\d\W])|。?。(= * \W)(= * \\?。 ?d))|(= * \W)(= * [AZ])(= * \d)){8}(:(= * [AZ])(????。 ?:|(?= * \W)(?= * \d)(?= * [AZ])(?= * [\d\W]))|(=?。 * \W)(= * [AZ])(= * \d)){8}(?:???(= * [AZ])(?:?(= * [ AZ])(= * [\d\W])|???(= * \W)(= * \d))|??(= * \W)(= * [AZ])(= * \d)){8}(?:。?(= * [AZ])(?:?(= * [AZ]。)(= *?。 [\d\W])|?(= * \W)(= * \d))|。?。(= * \W)(= * [AZ])(??? 。= * \d)){8}。(?:(= * [AZ])(?:?(= * [AZ])?(= * [\d\W] )|?(= * \W)(= * \d))|????(= * \W)(= * [AZ])(= * \d)) 。{8,}(:(= * [AZ])(?:?????(= * [AZ])(= * [\d\W])|(= * \\ ?\\W)(= * \d))|???。(= * \W)(= * [AZ])(= * \d)){8}(?: (?= * [AZ]。)(?:????(= * [AZ])(= * [\d\W])|(= * \W)(= * ?\d))|(= * \W)(= * [AZ])(= * \d)){8}(:(= * [AZ]????。 ):(= * [\d\W])|(= * \W?))|(((= * [AZ]?)(= * \d?)。? = * \W)(= * [AZ])(= * \d)){8}(。?。?。?。(= * [AZ])(?:?(=。 * [AZ])(= * [\d\W])|?(= * \W)(= * \d))|??(= * \W)(?。 ?=。* [AZ])(= * \d)){8}(?:。?(= * [AZ])(?:?(= * [AZ]。)(= * [\\?。 \\d\W])|?(= * \W)(= * \d))|??(= * \W)(= * [AZ])(=??。 * \d)){8}(:(= * [AZ])(?:???(= * [AZ])(?= * [\d\W])| (?= * \W)(?= * \d))|???。(= * \W)(= * [AZ])(= * \d)){ 8,}(:(= * [AZ])(?:?????(= * [AZ])(= * [\d\W])|(= * \W ?)(= * \d))|。?(= * \W)(= * [AZ])(= * \d)){8}(:(。?。?。? = * [AZ])(?:?(= * [AZ])。?(?= * [\d\W])|(?= * \W)(= * \ ?d))|(= * \W)(= * [AZ])(= * \d)){8}(:(= * [AZ])(????。 ?:|(?= * \W)(?= * \d)(?= * [AZ])(?= * [\d\W]))|(=?。 * \W)(= * [AZ])(= * \d)){8}(?:???(= * [AZ])(?:?(= * [ AZ])(= * [\d\W])|???(= * \W)(= * \d))|??(= * \W)(= * [AZ])(= * \d)){8}(?:。?(= * [AZ])(?:?(= * [AZ]。)(= *?。 [\d\W])|?(= * \W)(= * \d))|。?。(= * \W)(= * [AZ])(??? 。= * \d)){8}。(?:(= * [AZ])(?:?(= * [AZ])?(= * [\d\W] )|?(= * \W)(= * \d))|????(= * \W)(= * [AZ])(= * \d)) 。{8, }(:(= * [AZ])(?:?????(= * [AZ])(= * [\d\W])|(= * \W)( ??= * \d))|(= * \W)(= * [AZ])(= * \d)){8}(:(=????。 * [AZ]):(= * [\d\W])|(= * \d?)((= * [AZ]?)(= * \W?)。 )|(= * \W)(= * [AZ])(= * \d)){8}(?:????(= * [AZ])(?: (?= * [AZ]。)(= * [\d\W])|(= * \W?)(= * \d?))|?(= * \\ \\W)(= * [AZ])(= * \d)){8}(?:???(= * [AZ])(:?(= * [AZ] ?)(= * [\d\W])|。?。(= * \W)(= * \d))|???(= * \W)(= * [AZ])(= * \d)){8}(?:。?(= * [AZ])(?:?(= * [AZ]。)(= * [\\?。 \\d\W])|?(= * \W)(= * \d))|??(= * \W)(= * [AZ])(=??。 * \d)){8}(:(= * [AZ])(?:???(= * [AZ])(?= * [\d\W])| (?= * \W)(?= * \d))|???。(= * \W)(= * [AZ])(= * \d)){ 8,}(:(= * [AZ])(?:?????(= * [AZ])(= * [\d\W])|(= * \W ?)(= * \d))|。?(= * \W)(= * [AZ])(= * \d)){8}(:(。?。?。? = * [AZ])(?:?(= * [AZ])。?(?= * [\d\W])|(?= * \W)(= * \ ?d))|(= * \W)(= * [AZ])(= * \d)){8}(:(= * [AZ])(????。 ?:?(= * [ AZ])(= * [\d\W])|???(= * \W)(= * \d))|??(= * \W)(= * [AZ])(= * \d)){8}(?:。?(= * [AZ])(?:?(= * [AZ]。)(= *?。 [\d\W])|?(= * \W)(= * \d))|。?。(= * \W)(= * [AZ])(??? 。= * \d)){8}。(?:(= * [AZ])(?:?(= * [AZ])?(= * [\d\W] )|?(= * \W)(= * \d))|????(= * \W)(= * [AZ])(= * \d)) 。{8,}(:(= * [AZ])(?:?????(= * [AZ])(= * [\d\W])|(= * \\ ?\\W)(= * \d))|???。(= * \W)(= * [AZ])(= * \d)){8}(?: (?= * [AZ]。)(?:????(= * [AZ])(= * [\d\W])|(= * \W)(= * ?\d))|(= * \W)(= * [AZ])(= * \d)){8}(:(= * [AZ]????。 ):(= * [\d\W])|(= * \W?))|(((= * [AZ]?)(= * \d?)。? = * \W)(= * [AZ])(= * \d)){8}(。?。?。?。(= * [AZ])(?:?(=。 * [AZ])(= * [\d\W])|?(= * \W)(= * \d))|??(= * \W)(?。 ?= * [AZ])。(= * \d)){8}(?:。?(= * [AZ])(?:?(= * [AZ])?(= 。* [\d\W])|(= * \W)(= * \d))|????(= * \W)(= * [AZ]) (?= * \d)){8}(?:(= * [AZ]。)(?:??(= * [AZ])(= * [\d\ W])|??(= * \W)(= * \d))|(= * \W)(= * [AZ])(= * \d???。 。)){8}(:(= * [AZ])(:(= * [AZ]????)|(=(= * [\d\W])? * \W)(= * \d))|???(= * \W)(= * [AZ])(= * \d)){8}(?。 ?:(= * [AZ]。)(?:????(= * [AZ])(= * [\d\W])|(= * \W)(= * \d))|(= * \W)(= * [AZ])(= * \d)){8}(:(= * [?????。 AZ]):(= * [\d\W])|(= * \W?)(= * \d?))|((= * [AZ]?)。 (?= * \W)(= * [AZ]。)(= * \d?)){8}。(?:?(= * [AZ])(:(? ?= * [AZ])(= * [\d\W])|。(= * \W)(= * \d))|???(= * \W )(= * [AZ])(= * \d)){8}(?:?。?(= * [AZ])(?:?(= * [AZ])( ?= * [\d\W])|。?。?(= * \W)(= * \d))|。?。?。(= * \W)(= * [AZ ])(= * \d)){8}(?:。?(= * [AZ])(?:?(= * [AZ])?(= * [\d \W])|??(= * \W)(= * \d))|(= * \W)(= * [AZ])(= * \\???。 。\\d)){8}(= * [\d\W])|((:(= * [AZ])((= * [AZ]????)。? = * \W)(= * \d))|。????。(= * \W)(= * [AZ])(= * \d)){8, }(:(= * [AZ])(?:?????(= * [AZ])(= * [\d\W])|(= * \W)( ?=。* ?\\d))|(= * \W)(= * [AZ])(= * \d)){8}(:(= * [AZ])????。 (= |:((= * [AZ])(= * [\d\W])|(= * \W)(= * \d)?????)。? * \W)(= * [AZ])(= * \d)){8}(?:?。?(= * [AZ])(?:?(= *。 [AZ])(= * [\d\W])|??(= * \W)(= * \d))|。?。(= * \W)(?? 。= * [AZ])(?。= * \d)){8}(?:(= * [AZ])(?:?(= * [AZ])(=?。 * [\d\W])|(= * \W)(= * \d))|????(= * \W)(= * [AZ])( ?= * \d)){8}。(?:(= * [AZ])(?:?(= * [AZ])?(= * [\d\W ])|(= * \W)(= * \d))|?????(= * \W)(= * [AZ])(= * \d) (?:(= * [AZ]?)){8}(。???(= * [AZ])(= * [\d\W])|(= * \W)(= * \d))|????(= * \W)(= * [AZ])(= * \d)){8}(。? :(= * [AZ]。)(?:???(= * [AZ])(= * [\d\W])|(= * \W)(=?。 * \d))|(= * \W)(= * [AZ])(= * \d)){8}(?:(= * [AZ????。 ])(?:?(= * [AZ])(?= * [\d\W])|(?= * \W)(?= * \d))|( ?= * \W)(= * [AZ])(= * \d)){8}(?:?。?(= * [AZ])(?:?(= * [AZ])(= * [\d\W])|?(= * \W)(= * \d))|??(= * \W)?。 (?= * [AZ])(= * \d)){8}(?:。?(= * [AZ])(?:?(= * [AZ]。)(= *?。 [\d\W])|?(= * \W)(= * \d))|。?。(= * \W)(= * [AZ])(??? 。= * \d)){8}。(?:(= * [AZ])(?:?(= * [AZ])?(= * [\d\W] )|?(= * \W)(= * \d))|????(= * \W)(= * [AZ])(= * \d)) 。{8,}(:(= * [AZ])(?:?????(= * [AZ])(= * [\d\W])|(= * \\ ?\\W)(= * \d))|???。(= * \W)(= * [AZ])(= * \d)){8}(?: (?= * [AZ]。)(?:????(= * [AZ])(= * [\d\W])|(= * \W)(= * ?\d))|(= * \W)(= * [AZ])(= * \d)){8}(:(= * [AZ]????。 ):(= * [\d\W])|(= * \W?))|(((= * [AZ]?)(= * \d?)。? = * \W)(= * [AZ])(= * \d)){8}(。?。?。?。(= * [AZ])(?:?(=。 * [AZ])(= * [\d\W])|?(= * \W)(= * \d))|??(= * \W)(?。 ?= * [AZ])。(= * \d)){8}(?:。?(= * [AZ])(?:?(= * [AZ])?(= 。* [\d\W])|(= * \W)(= * \d))|????(= * \W)(= * [AZ]) (?= * \d)){8}(?:(= * [AZ]。)(?:??(= * [AZ])(= * [\d\ W])|??(= * \W)(= * \d))|(= * \W)(= * [AZ])(= * \d???。 )){ 8,}(:(= * [AZ])(?:?????(= * [AZ])(= * [\d\W])|(= * \W ?)(= * \d))|。?(= * \W)(= * [AZ])(= * \d)){8}(:(。?。?。? = * [AZ])(?:?(= * [AZ])。?(?= * [\d\W])|(?= * \W)(= * \ ?d))|(= * \W)(= * [AZ])(= * \d)){8}(:(= * [AZ])(????。 ?:|(?= * \W)(?= * \d)(?= * [AZ])(?= * [\d\W]))|(=?。 * \W)(= * [AZ])(= * \d)){8}(?:???(= * [AZ])(?:?(= * [ AZ])(= * [\d\W])|???(= * \W)(= * \d))|??(= * \W)(= * [AZ])(?=。* \d))。{8,}(^(?=。* \d)(?=。* [AZ])(?=。* [AZ]) ?(?= * [AZ])* $)(?。^(= * \d)(?= * [@#$%^&安培; + =])。* $)(^(? ?= * \d)(= * [AZ])(= * [@#$%^&安培; + =]????)* $)(^(= * [AZ]) (?= * [AZ])(?= * [@#$%^&安培; + =])* $)(^(= * \d?)(= * [AZ]。?。 )(= * [AZ])* $)(^(= * \d)(= * [AZ])(= * [@#$%^&安培;?????+ = ])* $)(^(= * \d)(= * [AZ])(= * [@#$%^&安培;?????+ =])* $)( (?= * [AZ])^(?= * [AZ])(?= * [@#$%^&安培; + =])。?。* $)(^(= * \ d)(?=。* [AZ])(?=。* [AZ])。* $)?(^(?=。* \d)(?=。* [AZ])(?=。* [@#$%^&安培; + =])* $)(^(= * \d)(= * [AZ])(=????。 * [@#$%^&安培; + =]。????)* $)(^(= * [AZ])(= * [AZ])(= * [@#$%^&安培; + =])* $)(^(= * \d)(= * [AZ])(= * [AZ])* $)(^(=??????。 ??* \d)(= * [AZ])(= * [@#$%^&安培; + =])* $)(^(= * \d)(=??? ?。* [AZ])(= * [@#$%^&安培; + =]。???)* $)(^(= * [AZ])(= * [AZ])(? = * [@#$%^&安培; + =]。????)* $)(^(= * \d)(= * [AZ])(= * [AZ])。 * $)(^(= * \d?)(= * [AZ]。)(= * [@#$%^&安培; + =])??* $)(^(? 。= * \d)(= * [AZ])(= * [@#$%^&安培; + =]。?。)* $)(^(= * [AZ])(。?。 ??= * [AZ])(= * [@#$%^&安培; + =])* $)(^(= * \d)(= * [AZ])。?。?。 (?= * [AZ])* $)(^(= * \d?)(= *?(= * [AZ]??)。[@#$%^&安培; + =] 。)* $)(^(= * \d)(= * [AZ])(= * [@#$%^&安培; + =]????)* $)(^。? (?= * [AZ])(?= * [AZ])(?= * [@#$%^&安培; + =])。?。* $)(^(= * \d )(?=。* [AZ])(?=。* [AZ])。* $)?(^(?=。* \d)(?=。* [AZ])(?=。* [ @#$%^&安培; + =])* $)(^(= * \d)(= * [AZ])(= * [@#$%^&安培;????+ 。=])* $)(^(= * [AZ])(= * [AZ])(= * [@#$%^&安培;???。+ =])* $)? (^(?=。* \d)(?=。* [AZ])(?=。* [AZ])。* $)?(^(?=。* \d)(?=。* [AZ])(= * [@#$%^&安培; + =]。???)* $)(^(= * \d)(= * [AZ])(=?。 * [@#$%^&安培; + =])* $)(^(= * [AZ])(。?。 ??= * [AZ])(= * [@#$%^&安培; + =])* $)(^(= * \d)(= * [AZ])。?。?。 (?= * [AZ])* $)(^(= * \d?)(= *?(= * [AZ]??)。[@#$%^&安培; + =] 。)* $)(^(= * \d)(= * [AZ])(= * [@#$%^&安培; + =]????)* $)(^。? (?= * [AZ])(?= * [AZ])(?= * [@#$%^&安培; + =])。?。* $)(^(= * \d )(?=。* [AZ])(?=。* [AZ])。* $)?(^(?=。* \d)(?=。* [AZ])(?=。* [ @#$%^&安培; + =])* $)(^(= * \d)(= * [AZ])(= * [@#$%^&安培;????+ 。=])* $)(^(= * [AZ])(= * [AZ])(= * [@#$%^&安培;???。+ =])* $)? (^(?=。* \d)(?=。* [AZ])(?=。* [AZ])。* $)?(^(?=。* \d)(?=。* [AZ])(= * [@#$%^&安培; + =]。???)* $)(^(= * \d)(= * [AZ])(=?。 * [@#$%^&安培; + =]。????)* $)(^(= * [AZ])(= * [AZ])(= * [@#$%^&安培; + =])* $)(^(= * \d)(= * [AZ])(= * [AZ])* $)(^(=??????。 ??* \d)(= * [AZ])(= * [@#$%^&安培; + =])* $)(^(= * \d)(=??? ?。* [AZ])(= * [@#$%^&安培; + =]。???)* $)(^(= * [AZ])(= * [AZ])(? = * [@#$%^&安培; + =]。????)* $)(^(= * \d)(= * [AZ])(= * [AZ])。 * $)(^(= * \d?)(= * [AZ]。)(= * [@#$%^&安培; + =])??* $)(^(? 。= * \d)(= * [AZ])(= * [@#$%^&安培; + =]。?。)* $)(^(= * [AZ])(。?。 ??= * [AZ])(= * [@#$%^&安培; + =])* $)。? (^(?=。* \d)(?=。* [AZ])(?=。* [AZ])。* $)?(^(?=。* \d)(?=。* [AZ])(= * [@#$%^&安培; + =]。???)* $)(^(= * \d)(= * [AZ])(=?。 * [@#$%^&安培; + =]。????)* $)(^(= * [AZ])(= * [AZ])(= * [@#$%^&安培; + =])* $)(^(= * \d)(= * [AZ])(= * [AZ])* $)(^(=??????。 ??* \d)(= * [AZ])(= * [@#$%^&安培; + =])* $)(^(= * \d)(=??? ?。* [AZ])(= * [@#$%^&安培; + =]。???)* $)(^(= * [AZ])(= * [AZ])(? = * [@#$%^&安培; + =]。????)* $)(^(= * \d)(= * [AZ])(= * [AZ])。 * $)(^(= * \d?)(= * [AZ]。)(= * [@#$%^&安培; + =])??* $)(^(? 。= * \d)(= * [AZ])(= * [@#$%^&安培; + =]。?。)* $)(^(= * [AZ])(。?。 ??= * [AZ])(= * [@#$%^&安培; + =])* $)(^(= * \d)(= * [AZ])。?。?。 (?= * [AZ])* $)(^(= * \d?)(= *?(= * [AZ]??)。[@#$%^&安培; + =] 。)* $)(^(= * \d)(= * [AZ])(= * [@#$%^&安培; + =]????)* $)(^。? (?= * [AZ])(?= * [AZ])(?= * [@#$%^&安培; + =])。?。* $)(^(= * \d )(?=。* [AZ])(?=。* [AZ])。* $)?(^(?=。* \d)(?=。* [AZ])(?=。* [ @#$%^&安培; + =])* $)(^(= * \d)(= * [AZ])(= * [@#$%^&安培;????+ 。=])* $)(^(= * [AZ])(= * [AZ])(= * [@#$%^&安培;???。+ =])* $)? (^(?=。* \d)(?=。* [AZ])(?=。* [AZ 。?。])* $)(^(= * \d)(= * [AZ])(= * [@#$%^&安培;??。+ =])* $)(? ^(?= * \d)(= * [AZ]。)(= * [@#$%^&安培; + =]。)* $)(^(= * [AZ。?。 ??])(= * [AZ])(= * [@#$%^&安培;???+ =])* $)(^(= * \d)(= * [ ?????AZ])(= * [AZ])* $)(^(= * \d)(= * [AZ])(= * [@#$%^&安培; ????+ =])* $)(^(= * \d)(= * [AZ])(= * [@#$%^&安培; + =])* $)。 ?(???。^(= * [AZ])(= * [AZ])(= * [@#$%^&安培; + =])* $。)(^(= *?。 \d)(?=。* [AZ])(?=。* [AZ])。* $)?(^(?=。* \d)(?=。* [AZ])(?= 。* [@#$%^&安培; + =])* $)(^(= * \d)(= * [AZ])(= * [@#$%^。???。 &安培; + =])* $)(^(= * [AZ])(= * [AZ])(= * [@#$%^&安培;????。+ =])* $)?(^(?=。* \d)(?=。* [AZ])(?=。* [AZ])。* $)?(^(?=。* \d)(? = * [AZ])(= * [@#$%^&安培; + =]。?。?。?。)* $)(^(= * \d)(= * [AZ])( ?= * [@#$%^&安培; + =]。????)* $)(^(= * [AZ])(= * [AZ])(= * [@#$ %^&安培; + =])* $)(^(= * \d)(= * [AZ])(= * [AZ])* $)(^(????? ?= * \d)(= * [AZ])(= * [@#$%^&安培; + =]????)* $)(^(= * \d) (?= * [AZ])(?= * [@#$%^&安培; + =])。?。* $)(?。^(= * [AZ])(= * [AZ] ?)(= *。???[@#$%^&安培; + =])* $)(^(= * \d)(= * [AZ])(= * [AZ ])。* $)?(^(?=。* \d)(?=。* [AZ])(? = * [@#$%^&安培; + =]。????)* $)(^(= * \d)(= * [AZ])(= * [@#$% ^&安培;?。+ =])* $)(^(= * [AZ])(= * [AZ])(= * [@#$%^&安培;??+ =])。 * $)?(^(?=。* \d)(?=。* [AZ])(?=。* [AZ])。* $)?(^(?=。* \d)( ??= * [AZ])(= * [@#$%^&安培; + =])* $)(^(= * \d)(= * [AZ])。?。?。 (= *?。[@#$%^&安培; + =])。?。* $)(?。^(= * [AZ])(?= * [AZ])(= * [@# $%^&安培; + =])* $)(^(= * \d)(= * [AZ])(= * [AZ])* $)(^。???。? (?= * \d)(= * [AZ]。)(= * [@#$%^&安培; + =])。* $)(^(= * \d?。 ??)(= * [AZ])(= * [@#$%^&安培; + =])* $)(^(= * [AZ])(= * [AZ。?。?。 ?])(= * [@#$%^&安培; + =])* $)(^(= * \d)(= * [AZ])(= * [????。 ????AZ])* $)(^(= * \d)(= * [AZ])(= * [@#$%^&安培; + =])* $)? (?。^(= * \d)(= * [AZ])(= * [@#$%^&安培; + =]。?。)* $。)(^(= * [?。 AZ])(= * [AZ])(= * [@#$%^&安培;??+ =])* $)(^(= * \d)(= *。?。?。 [AZ])(?=。* [AZ])。* $)?(^(?=。* \d)(?=。* [AZ])(?=。* [@#$%^&安培+ =])* $)(^(= * \d)(= * [AZ])(= * [@#$%^&安培;????。+ =])* $ )(^(= * [AZ]。)?(= * [AZ]。)(= * [@#$%^&安培; + =]。)* $)(^(=。?。 * \d)(?=。* [AZ])(?=。* [AZ])。* $)?(^(?=。* \d)(?=。* [AZ])(? = * [@#$%^&安培; + =])* $)(^(= * \\。?。 ??d)(= * [AZ])(= * [@#$%^&安培; + =]。???)* $)(^(= * [AZ])(= * [ ?AZ])(= * [@#$%^&安培; + =])* $)(^(= * \d)(= * [AZ])(= *。???。 ????[AZ])* $)(^(= * \d)(= * [AZ])(= * [@#$%^&安培; + =])* $)。 ?(???。^(= * \d)(= * [AZ])(= * [@#$%^&安培; + =])* $。)(^(= *?。 [AZ])(= * [AZ])(= * [@#$%^&安培; + =]???)* $)(^(= * \d)(=??。 * [AZ])(?=。* [AZ])。* $)?(^(?=。* \d)(?=。* [AZ])(?=。* [@#$%^ &安培; + =])* $)(^(= * \d)(= * [AZ])(= * [@#$%^&安培;????。+ =])* $)(^(= * [AZ]。)(= * [AZ]。)(= * [@#$%^&安培; + =]。)?* $)(^(=。? * \d)(?=。* [AZ])(?=。* [AZ])。* $)?(^(?=。* \d)(?=。* [AZ])( ?= *。???[@#$%^&安培; + =])* $)(^(= * \d)(= * [AZ])(= * [@#$ %^&安培; + =])* $)(^(= * [AZ])(= * [AZ])(= * [@#$%^&安培;????+ =]) * $)?(^(?=。* \d)(?=。* [AZ])(?=。* [AZ])。* $)?(^(?=。* \d) (?= * [AZ]。)(= * [@#$%^&安培; + =]?)。?。* $)(?。^(= * \d)(= * [AZ] ?)(= * [@#$%^&安培; + =]。????)* $)(^(= * [AZ])(= * [AZ])(= * [@ #$%^&安培; + =])* $)(^(= * \d)(= * [AZ])(= * [AZ])* $)(????。? ^(?= * \d)(= * [AZ]。)(= * [@#$%^&安培; + =]?)。?。* $)(^(= * \ d)(= * [AZ])(= *?。?[@#$%^&安培; + =])。 ?* $)(?。^(= * [AZ])(?= * [AZ])(?= * [@#$%^&安培; + =])。* $)(^(? =。* \d)(?=。* [AZ])(?=。* [AZ])。* $)?(^(?=。* \d)(?=。* [AZ]) (= *?。[@#$%^&安培; + =])。?。* $)(?。^(= * \d)(?= * [AZ])(= * [@# $%^&安培;???+ =])* $)(^(= * [AZ])(= * [AZ])(= * [@#$%^&安培;。+ =] )。* $)?(^(?=。* \d)(?=。* [AZ])(?=。* [AZ])。* $)?(^(?=。* \d ??)(= * [AZ])(= * [@#$%^&安培; + =])* $)(^(= * \d)(= * [AZ。?。?。 ?])(= * [@#$%^&安培;????+ =])* $)(^(= * [AZ])(= * [AZ])(= * [ @#$%^&安培; + =])* $)(^(= * \d)(= * [AZ])(= * [AZ])* $)????? (???。^(= * \d)(= * [AZ])(= * [@#$%^&安培; + =])* $)(^(= * \\?。 ??\\d)(= * [AZ])(= * [@#$%^&安培; + =])* $)(^(= * [AZ])(= *。?。?。 [AZ])(= * [@#$%^&安培; + =]。)* $)(^(= * \d)(= * [AZ])(=????。 ????* [AZ])* $)(^(= * \d)(= * [AZ])(= * [@#$%^&安培; + =])* $。 ?(?。^(= * \d))(?= * [AZ])(= * [@#$%^&安培; + =]。)* $)(^(=。?。 ??。* [AZ])(= * [AZ])(= * [@#$%^&安培; + =])* $)(^(= * \d)(=??? * [AZ])(?=。* [AZ])。* $)?(^(?=。* \d)(?=。* [AZ])(?=。* [@#$% ^&安培;?+ =])* $)(^(= * \d)(= * [AZ])(= * [@#$%^&安培;??+ =])。 * $)?(^(?=。* [AZ])(?=。* [AZ])(?=。* [@ #$%^&安培; + =])* $)(^(= * \d)(= * [AZ])(= * [AZ])* $)(????。? ^(?= * \d)(= * [AZ]。)(= * [@#$%^&安培; + =]?)。?。* $)(^(= * \ ??d)(= * [AZ])(= * [@#$%^&安培; + =]。???)* $)(^(= * [AZ])(= * [ ?AZ])(= * [@#$%^&安培; + =])* $)(^(= * \d)(= * [AZ])(= *。???。 ????[AZ])* $)(^(= * \d)(= * [AZ])(= * [@#$%^&安培; + =])* $)。 ?(???。^(= * \d)(= * [AZ])(= * [@#$%^&安培; + =])* $。)(^(= *?。 [AZ])(= * [AZ])(= * [@#$%^&安培; + =]???)* $)(^(= * \d)(=??。 * [AZ])(?=。* [AZ])。* $)?(^(?=。* \d)(?=。* [AZ])(?=。* [@#$%^ &安培; + =])* $)(^(= * \d)(= * [AZ])(= * [@#$%^&安培;????。+ =])* $)(^(= * [AZ]。)(= * [AZ]。)(= * [@#$%^&安培; + =]。)?* $)(^(=。? * \d)(?=。* [AZ])(?=。* [AZ])。* $)?(^(?=。* \d)(?=。* [AZ])( ?= *。???[@#$%^&安培; + =])* $)(^(= * \d)(= * [AZ])(= * [@#$ %^&安培; + =])* $)(^(= * [AZ])(= * [AZ])(= * [@#$%^&安培;????+ =]) * $)?(^(?=。* \d)(?=。* [AZ])(?=。* [AZ])。* $)?(^(?=。* \d) (?= * [AZ]。)(= * [@#$%^&安培; + =]?)。?。* $)(?。^(= * \d)(= * [AZ] ?)(= * [@#$%^&安培; + =]。????)* $)(^(= * [AZ])(= * [AZ])(= * [@ #$%^&安培;?。+ =])* $)(^(= * \d)(? =。* [AZ])(?=。* [AZ])。* $)?(^(?=。* \d)(?=。* [AZ])(?=。* [@#$ %^&安培; + =])* $)(^(= * \d)(= * [AZ])(= * [@#$%^&安培;????+ =]) * $)(^(= * [AZ]。)(= * [AZ]。)(= * [@#$%^&安培; + =])?* $)(^(? ?=。* \d)(?=。* [AZ])(?=。* [AZ])。* $)?(^(?=。* \d)(?=。* [AZ] ?)(= * [@#$%^&安培; + =]。????)* $)(^(= * \d)(= * [AZ])(= * [@ #$%^&安培; + =])* $)(^(= * [AZ])(= * [AZ])(= * [@#$%^&安培;????+ = ])。* $)?(^(?=。* \d)(?=。* [AZ])(?=。* [AZ])。* $)?(^(?=。* \ ??d)(= * [AZ])(= * [@#$%^&安培; + =]。???)* $)(^(= * \d)(= * [ ?AZ])(= * [@#$%^&安培; + =])* $)(^(= * [AZ])(= * [AZ])(= *。???。 ????。[@#$%^&安培; + =])* $)(^(= * \d)(= * [AZ])(= * [AZ])* $) ?(???。^(= * \d)(= * [AZ])(= * [@#$%^&安培; + =])* $。)(^(= *?。 \d)(= * [AZ])(= * [@#$%^&安培; + =]。?。)* $)(^(= * [AZ])(=???。 ?。* [AZ])(= * [@#$%^&安培; + =])* $)(^(= * \d)(= * [AZ])(=???? * [AZ])* $)(^(= * \d)(= * [AZ])(= * [@#$%^&安培; + =]。????)。*。 ?$)(?。^(= * \d)(?= * [AZ])(?= * [@#$%^&安培; + =])* $)(^(=。? ??。* [AZ])(= * [AZ])(= * [@#$%^&安培; + =])* $)(^(= * \d)(??? =。* [AZ])(?=。* [AZ])。* $)?(^(?=。* \\ ??\\d)(= * [AZ])(= * [@#$%^&安培; + =])* $)(^(= * \d)(= *。?。?。 [AZ])(= * [@#$%^&安培; + =]。???)* $)(^(= * [AZ])(= * [AZ])(=?。 * [@#$%^&安培; + =]。????。)* $)(^(= * \d)(= * [AZ])(= * [AZ])* $ )?(^(= * \d?)(= * [AZ]?)。?(= * [@#$%^&安培; + =]。)* $)(^(=?。 ?* \d)(= * [AZ])(= * [@#$%^&安培; + =]。?。???)* $)(^(= * [AZ])(= ?。* [AZ])(= * [@#$%^&安培; + =])* $)(^(= * \d)(= * [AZ])(???? 。= * [AZ])* $)(^(= * \d)(= * [AZ])(= * [@#$%^&安培; + =]????)。 * $)(^(= * \d?)(= * [AZ]。)(= * [@#$%^&安培; + =])?* $)(^(? ??。= * [AZ])(= * [AZ])(= * [@#$%^&安培; + =]。?。)* $)(^(= * \d)( ?=。* [AZ])(?=。* [AZ])。* $)?(^(?=。* \d)(?=。* [AZ])(?=。* [@# $%^&安培;???+ =])* $)(^(= * \d)(= * [AZ])(= * [@#$%^&安培;?+ =] 。)* $)(^(= * [AZ])(= * [AZ])(= * [@#$%^&安培; + =]????。)* $)(^? (?=。* \d)(?=。* [AZ])(?=。* [AZ])。* $)?(^(?=。* \d)(?=。* [AZ ?])(= * [@#$%^&安培; + =])* $)(^(= * \d)(= * [AZ])(= * [????。 @#$%^&安培; + =])* $)(^(= * [AZ])(= * [AZ])(= * [@#$%^&安培;????+ =])。* $)?(^(?=。* \d)(?=。* [AZ])(?=。* [AZ])。* $)?(^(?=。* \\ \\d)(= * [AZ])(= *?。?[@#$%^&安培; + =] 。)* $)(^(= * \d)(= * [AZ])(= * [@#$%^&安培; + =]????)* $)(^。? (?= * [AZ])(?= * [AZ])(?= * [@#$%^&安培; + =])。?。* $)(^(= * \d )(?=。* [AZ])(?=。* [AZ])。* $)?(^(?=。* \d)(?=。* [AZ])(?=。* [ @#$%^&安培; + =])* $)(^(= * \d)(= * [AZ])(= * [@#$%^&安培;????+ 。=])* $)(^(= * [AZ])(= * [AZ])(= * [@#$%^&安培;???。+ =])* $)? (^(?=。* \d)(?=。* [AZ])(?=。* [AZ])。* $)?(^(?=。* \d)(?=。* [AZ])(= * [@#$%^&安培; + =]。???)* $)(^(= * \d)(= * [AZ])(=?。 * [@#$%^&安培; + =]。????)* $)(^(= * [AZ])(= * [AZ])(= * [@#$%^&安培; + =])* $)(^(= * \d)(= * [AZ])(= * [AZ])* $)(^(=??????。 ??* \d)(= * [AZ])(= * [@#$%^&安培; + =])* $)(^(= * \d)(=??? ?。* [AZ])(= * [@#$%^&安培; + =]。???)* $)(^(= * [AZ])(= * [AZ])(? = * [@#$%^&安培; + =]。????)* $)(^(= * \d)(= * [AZ])(= * [AZ])。 * $)(^(= * \d?)(= * [AZ]。)(= * [@#$%^&安培; + =])??* $)(^(? 。= * \d)(= * [AZ])(= * [@#$%^&安培; + =]。?。)* $)(^(= * [AZ])(。?。 ??= * [AZ])(= * [@#$%^&安培; + =])* $)(^(= * \d)(= * [AZ])。?。?。 (?= * [AZ])* $)(^(= * \d?)(= *?(= * [AZ]??)。[@#$%^&安培; + =] )。* $)?(^(?=。* \d)(?=。* [AZ])(?= 。* [@#$%^&安培; + =])* $)(^(= * [AZ])(= * [AZ])(= * [@#$%^。???。 &安培; + =])* $)(^(= * \d)(= * [AZ])(= * [AZ])* $)(^(=?????? * \d)(= * [AZ])(= * [@#$%^&安培; + =]???)* $)(^(= * \d)(?? = * [AZ])(= * [@#$%^&安培; + =]。?。?。?。)* $)(^(= * [AZ])(= * [AZ])( ?= * [@#$%^&安培; + =]。????)* $)(^(= * \d)(= * [AZ])(= * [AZ]) ?(?= * [AZ])* $)(?。^(= * \d)(?= * [@#$%^&安培; + =])。* $)(^(? ?= * \d)(= * [AZ])(= * [@#$%^&安培; + =]????)* $)(^(= * [AZ]) (?= * [AZ])(?= * [@#$%^&安培; + =])* $)(^(= * \d?)(= * [AZ]。?。 )(= * [AZ])* $)(^(= * \d)(= * [AZ])(= * [@#$%^&安培;?????+ = ])* $)(^(= * \d)(= * [AZ])(= * [@#$%^&安培;?????+ =])* $)( (?= * [AZ])^(?= * [AZ])(?= * [@#$%^&安培; + =])。?。* $)(^(= * \ d)(?=。* [AZ])(?=。* [AZ])。* $)?(^(?=。* \d)(?=。* [AZ])(?=。* [@#$%^&安培; + =])* $)(^(= * \d)(= * [AZ])(= * [@#$%^&安培。???。 + =])* $)(^(= * [AZ])(= * [AZ])(= * [@#$%^&安培;????。+ =])* $) ?(^(?=。* \d)(?=。* [AZ])(?=。* [AZ])。* $)?(^(?=。* \d)(?=。 ?。* [AZ])(= * [@#$%^&安培; + =])* $)(^(= * \d)(= * [AZ])(=???? 。* [@#$%^&安培; + =]。?。)* $)(^(= * [AZ]) (?= * [AZ])(?= * [@#$%^&安培; + =])* $)(^(= * \d?)(= * [AZ]。?。 )(= * [AZ])* $)(^(= * \d)(= * [AZ])(= * [@#$%^&安培;?????+ = ])* $)(^(= * \d)(= * [AZ])(= * [@#$%^&安培;?????+ =])* $)( (?= * [AZ])^(?= * [AZ])(?= * [@#$%^&安培; + =])。?。* $)(^(= * \ d)(?=。* [AZ])(?=。* [AZ])。* $)?(^(?=。* \d)(?=。* [AZ])(?=。* [@#$%^&安培; + =])* $)(^(= * \d)(= * [AZ])(= * [@#$%^&安培。???。 + =])* $)(^(= * [AZ])(= * [AZ])(= * [@#$%^&安培;????。+ =])* $) ?(^(?=。* \d)(?=。* [AZ])(?=。* [AZ])。* $)?(^(?=。* \d)(?=。 ?。* [AZ])(= * [@#$%^&安培; + =])* $)(^(= * \d)(= * [AZ])(=???? 。* [@#$%^&安培; + =])* $)(^(= * [AZ])(= * [AZ])(= * [@#$%^。???。 &安培; + =])* $)(^(= * \d)(= * [AZ])(= * [AZ])* $)(^(=?????? * \d)(= * [AZ])(= * [@#$%^&安培; + =]???)* $)(^(= * \d)(?? = * [AZ])(= * [@#$%^&安培; + =]。?。?。?。)* $)(^(= * [AZ])(= * [AZ])( ?= * [@#$%^&安培; + =]。????)* $)(^(= * \d)(= * [AZ])(= * [AZ]) ?(?= * [AZ])* $)(?。^(= * \d)(?= * [@#$%^&安培; + =])。* $)(^(? ?= * \d)(= * [AZ])(= * [@#$%^&安培; + =]????)* $)(^(= * [AZ]) (?= * [AZ])(?= * [@#$%^&安培; + =])* $)。 ?(^(?=。* \d)(?=。* [AZ])(?=。* [AZ])。* $)?(^(?=。* \d)(?=。 ?。* [AZ])(= * [@#$%^&安培; + =])* $)(^(= * \d)(= * [AZ])(=???? 。* [@#$%^&安培; + =])* $)(^(= * [AZ])(= * [AZ])(= * [@#$%^。???。 &安培; + =])* $)(^(= * \d)(= * [AZ])(= * [AZ])* $)(^(=?????? * \d)(= * [AZ])(= * [@#$%^&安培; + =]???)* $)(^(= * \d)(?? = * [AZ])(= * [@#$%^&安培; + =]。?。?。?。)* $)(^(= * [AZ])(= * [AZ])( ?= * [@#$%^&安培; + =]。????)* $)(^(= * \d)(= * [AZ])(= * [AZ]) ?(?= * [AZ])* $)(?。^(= * \d)(?= * [@#$%^&安培; + =])。* $)(^(? ?= * \d)(= * [AZ])(= * [@#$%^&安培; + =]????)* $)(^(= * [AZ]) (?= * [AZ])(?= * [@#$%^&安培; + =])* $)(^(= * \d?)(= * [AZ]。?。 )(= * [AZ])* $)(^(= * \d)(= * [AZ])(= * [@#$%^&安培;?????+ = ])* $)(^(= * \d)(= * [AZ])(= * [@#$%^&安培;?????+ =])* $)( (?= * [AZ])^(?= * [AZ])(?= * [@#$%^&安培; + =])。?。* $)(^(= * \ d)(?=。* [AZ])(?=。* [AZ])。* $)?(^(?=。* \d)(?=。* [AZ])(?=。* [@#$%^&安培; + =])* $)(^(= * \d)(= * [AZ])(= * [@#$%^&安培。???。 + =])* $)(^(= * [AZ])(= * [AZ])(= * [@#$%^&安培;????。+ =])* $) ?(^(?=。* \d)(?=。* [AZ])(?=。* [A- ????Z])* $)(^(= * \d)(= * [AZ])(= * [@#$%^&安培; + =])* $)? (?。^(= * \d)(= * [AZ])(= * [@#$%^&安培; + =]。?。)* $。)(^(= * [?。 AZ])(= * [AZ])(= * [@#$%^&安培;??+ =])* $)(^(= * \d)(= *。?。?。 [AZ])(?=。* [AZ])。* $)?(^(?=。* \d)(?=。* [AZ])(?=。* [@#$%^&安培+ =])* $)(^(= * \d)(= * [AZ])(= * [@#$%^&安培;????。+ =])* $ )(^(= * [AZ]。)?(= * [AZ]。)(= * [@#$%^&安培; + =]。)* $)(^(=。?。 * \d)(?=。* [AZ])(?=。* [AZ])。* $)?(^(?=。* \d)(?=。* [AZ])(? = * [@#$%^&安培; + =]。????)* $)(^(= * \d)(= * [AZ])(= * [@#$% ^&安培;?。+ =])* $)(^(= * [AZ])(= * [AZ])(= * [@#$%^&安培;??+ =])。 * $)?(^(?=。* \d)(?=。* [AZ])(?=。* [AZ])。* $)?(^(?=。* \d)( ??= * [AZ])(= * [@#$%^&安培; + =])* $)(^(= * \d)(= * [AZ])。?。?。 (= *?。[@#$%^&安培; + =])。?。* $)(?。^(= * [AZ])(?= * [AZ])(= * [@# $%^&安培; + =])* $)(^(= * \d)(= * [AZ])(= * [AZ])* $)(^。???。? (?= * \d)(= * [AZ]。)(= * [@#$%^&安培; + =])。* $)(^(= * \d?。 ??)(= * [AZ])(= * [@#$%^&安培; + =])* $)(^(= * [AZ])(= * [AZ。?。?。 ])(= * [@#$%^&安培;。+ =])* $)$ /);}?console.time( '1'); isFooBar( 富); console.timeEnd( 1' ),C onsole.time( '2'); isFooBar( 酒吧); console.timeEnd( '2'); (打开你的控制台并运行上面的代码片段,看看你的浏览器是否有结果。) 在节点上。 js 0.10.36(V8 3.14.5.9): 1:65ms 2:0ms 在io.js 1.6.3(V8 4.1.0.27): 1:32ms 2:0ms 所以,我猜你问题的答案是是,V8能够自动缓存正则表达式。 编辑: 即使V8 能够进行此类优化,其实可能选择始终使用此优化。 V8针对不同的情况提供了许多复杂的启发式方法,例如何时内联函数,何时优化函数,何时对函数进行去优化等。除非您是V8开发人员,否则许多这些启发式方法似乎都是奇异或意外的或两者。 我自己不是V8开发人员,我不知道是否总是自动缓存正则表达式的具体问题的答案。但是,即使我知道答案,也可能在将来发生变化。因此,当您编写代码时,我仍然建议以这样一种方式存储正则表达式,即清楚该变量的用途是什么。对于上面的示例,这意味着将正则表达式变量提升函数 isFooBar()。 另一个问题是如何创建此正则表达式。以上和OP的问题中的示例使用正则表达式声明文字。但是,如果您使用的是 新的RegExp()构造函数,V8 不允许缓存正则表达式,因为它可能在运行时更改。 So I know that in Javascript instantiating a regex causes it to be compiled automatically and if that regex is stored in a variable it will be reused without recompiling. Example:var re = /[Ff]oo|[Bb]ar/;"Foo".match(re); // ["Foo"]"Baz".match(re); // nullHowever, are duplicated regular expressions recompiled or does V8 (Chrome/Node.js) intelligently re-use them (like PHP does with preg_* functions)?function isFooBar(str) { return str.match(/[Ff]oo|[Bb]ar/);}isFooBar("Foo"); // ["Foo"]isFooBar("Baz"); // nullSo to clarify, I know the first example results in one compilation of the regex. But what about the second example? 解决方案 Well, let's find out.// http://stackoverflow.com/questions/3466850/complex-password-regular-expressionfunction isFooBar(str) { return str.match(/^(?:(?=.*[a-z])(?:(?=.*[A-Z])(?=.*[\d\W])|(?=.*\W)(?=.*\d))|(?=.*\W)(?=.*[A-Z])(?=.*\d)).{8,}(?:(?=.*[a-z])(?:(?=.*[A-Z])(?=.*[\d\W])|(?=.*\W)(?=.*\d))|(?=.*\W)(?=.*[A-Z])(?=.*\d)).{8,}(?:(?=.*[a-z])(?:(?=.*[A-Z])(?=.*[\d\W])|(?=.*\W)(?=.*\d))|(?=.*\W)(?=.*[A-Z])(?=.*\d)).{8,}(?:(?=.*[a-z])(?:(?=.*[A-Z])(?=.*[\d\W])|(?=.*\W)(?=.*\d))|(?=.*\W)(?=.*[A-Z])(?=.*\d)).{8,}(?:(?=.*[a-z])(?:(?=.*[A-Z])(?=.*[\d\W])|(?=.*\W)(?=.*\d))|(?=.*\W)(?=.*[A-Z])(?=.*\d)).{8,}(?:(?=.*[a-z])(?:(?=.*[A-Z])(?=.*[\d\W])|(?=.*\W)(?=.*\d))|(?=.*\W)(?=.*[A-Z])(?=.*\d)).{8,}(?:(?=.*[a-z])(?:(?=.*[A-Z])(?=.*[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^(?=.*\d)(?=.*[a-z])(?=.*[A-Z]).*$)?(^(?=.*\d)(?=.*[a-z])(?=.*[@#$%^&+=]).*$)?(^(?=.*\d)(?=.*[A-Z])(?=.*[@#$%^&+=]).*$)?(^(?=.*[a-z])(?=.*[A-Z])(?=.*[@#$%^&+=]).*$)?(^(?=.*\d)(?=.*[a-z])(?=.*[A-Z]).*$)?(^(?=.*\d)(?=.*[a-z])(?=.*[@#$%^&+=]).*$)?(^(?=.*\d)(?=.*[A-Z])(?=.*[@#$%^&+=]).*$)?(^(?=.*[a-z])(?=.*[A-Z])(?=.*[@#$%^&+=]).*$)?(^(?=.*\d)(?=.*[a-z])(?=.*[A-Z]).*$)?(^(?=.*\d)(?=.*[a-z])(?=.*[@#$%^&+=]).*$)?(^(?=.*\d)(?=.*[A-Z])(?=.*[@#$%^&+=]).*$)?(^(?=.*[a-z])(?=.*[A-Z])(?=.*[@#$%^&+=]).*$)?(^(?=.*\d)(?=.*[a-z])(?=.*[A-Z]).*$)?(^(?=.*\d)(?=.*[a-z])(?=.*[@#$%^&+=]).*$)?(^(?=.*\d)(?=.*[A-Z])(?=.*[@#$%^&+=]).*$)?(^(?=.*[a-z])(?=.*[A-Z])(?=.*[@#$%^&+=]).*$)?$/);}console.time('1');isFooBar("Foo");console.timeEnd('1');console.time('2');isFooBar("Bar");console.timeEnd('2');(Open your console and run the code snippet above to see if the results for your browser.)On Node.js 0.10.36 (V8 3.14.5.9):1: 65ms2: 0msOn io.js 1.6.3 (V8 4.1.0.27):1: 32ms2: 0msSo, I guess the answer to your question is YES, V8 is capable of automatically caching the regex.EDIT:Even though V8 is capable of such optimization, it might not in fact choose to always use this optimization. V8 has many complex heuristics for different cases, like when to inline a function, when to optimize a function, when to de-optimize a function, etc. Unless you are a V8 developer, many of these heuristics would appear to be bizarre or unexpected or both.Not being a V8 developer myself, I do not know the answer to the specific question of if regexes are always automatically cached. However, even if I do know the answer, it may change in the future. So when you are writing code, I would still recommend storing the regex in such a way that it is clear what the intention for this variable is. And for the example above, this means lifting the regex variable out of the function isFooBar().Another issue is how this regex is created. The example above and in OP's question are declared with a regular expression literal. However, if you are using the new RegExp() constructor, V8 would not be allowed to cache the regex since it might change during runtime. 这篇关于V8是否自动缓存编译的正则表达式?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 10-27 06:09