By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
460,034 Members | 979 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 460,034 IT Pros & Developers. It's quick & easy.

regx, global efficiencies?

P: n/a
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.

Jun 27 '08 #1
Share this Question
Share on Google+
4 Replies


P: n/a
On Jun 9, 5:43 pm, oldyork90 <oldyor...@yahoo.comwrote:
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);
Jun 27 '08 #2

P: n/a
On Jun 10, 8:45 am, oldyork90 <oldyor...@yahoo.comwrote:
On Jun 9, 5:43 pm, oldyork90 <oldyor...@yahoo.comwrote:
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.
--
Rob
--
Rob
Jun 27 '08 #3

P: n/a
oldyork90 wrote:
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
--
Use any version of Microsoft Frontpage to create your site.
(This won't prevent people from viewing your source, but no one
will want to steal it.)
-- from <http://www.vortex-webdesign.com/help/hidesource.htm>
Jun 27 '08 #4

P: n/a
On Jun 9, 7:47 pm, RobG <rg...@iinet.net.auwrote:
On Jun 10, 8:45 am, oldyork90 <oldyor...@yahoo.comwrote:
On Jun 9, 5:43 pm, oldyork90 <oldyor...@yahoo.comwrote:
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.

--
Rob

--
Rob
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.
Jun 27 '08 #5

This discussion thread is closed

Replies have been disabled for this discussion.