regx, global efficiencies?

O

oldyork90

If we toss this in a global area, is it compiled just once one the js
file is included in the new page?

var re = /[^\x09-\x0D\x20-\x7E]/o

Thank you.
 
O

oldyork90

If we toss this in a global area, is it compiled just once one the js
file is included in the new page?

var re = /[^\x09-\x0D\x20-\x7E]/o

Thank you.

whoops.. this too
var regex = new RegExp(re);
 
R

RobG

If we toss this in a global area, is it compiled just once one the js
file is included in the new page?
var re = /[^\x09-\x0D\x20-\x7E]/o
Thank you.

whoops.. this too
var regex = new RegExp(re);

Yes.

What benefit is there is to calling RegExp as a constructor with re as
the argument whey you've already initalised re as a regular
expression. As far as I know, it just creates another instance of re
(i.e. re is effectively === regexp).

Oh, there is no 'o' flag, ECMAScript has only g, i and m flags.
 
T

Thomas 'PointedEars' Lahn

oldyork90 said:
If we toss this in a global area, is it compiled just once one the js
file is included in the new page?

var re = /[^\x09-\x0D\x20-\x7E]/o

It does not compile because `o' is an unsupported flag. Unless, of course,
you are using an implementation that extends ECMAScript to support it. For
everything else (including your followup), please read the ECMAScript
Specification, Edition 3 Final.


PointedEars
 
O

oldyork90

If we toss this in a global area, is it compiled just once one the js
file is included in the new page?
var re = /[^\x09-\x0D\x20-\x7E]/o
Thank you.
whoops.. this too
var regex = new RegExp(re);

Yes.

What benefit is there is to calling RegExp as a constructor with re as
the argument whey you've already initalised re as a regular
expression. As far as I know, it just creates another instance of re
(i.e. re is effectively === regexp).

Oh, there is no 'o' flag, ECMAScript has only g, i and m flags.

Thanks Rob. Ok then, 'var re = /[^\x09-\x0D\x20-\x7E]/' is all I
need. I wasn't sure if that actually
compiled the expression on not. I thought perhaps all it did was
assign a string. FYI, that 'o' was a perl
artifact I guess. Thanks again.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,764
Messages
2,569,564
Members
45,039
Latest member
CasimiraVa

Latest Threads

Top