Inline regexps and caching

Mark S. Miller erights at google.com
Fri Jan 23 07:54:52 PST 2009


On Fri, Jan 23, 2009 at 7:33 AM, Mike Shaver <mike.shaver at gmail.com> wrote:

> Firefox and Opera are doing what ES3 requires (s 7.8.5:
> http://bclary.com/2004/11/07/#a-7.8.5 ),


Correct.


> but I believe that it's being
> changed in 3.1 to produce a new one each time the literal expression
> is executed.
>

Correct. In the meantime, you can change expressions like

    var regexp = /^[^d]*\bd{1,4}\b[^d]*$/g;

into

    var regexp = new RegExp("^[^d]*\\bd{1,4}\\b[^d]*$","g");

Yes, this is ugly. But an ugly program that works is better than a pretty
one that doesn't.


-- 
   Cheers,
   --MarkM
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20090123/35d55691/attachment.html>


More information about the Es-discuss mailing list