Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Javascript > regx, global efficiencies?

Reply
Thread Tools

regx, global efficiencies?

 
 
oldyork90
Guest
Posts: n/a
 
      06-09-2008
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.

 
Reply With Quote
 
 
 
 
oldyork90
Guest
Posts: n/a
 
      06-09-2008
On Jun 9, 5:43 pm, oldyork90 <(E-Mail Removed)> 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
>
> Thank you.


whoops.. this too
var regex = new RegExp(re);
 
Reply With Quote
 
 
 
 
RobG
Guest
Posts: n/a
 
      06-10-2008
On Jun 10, 8:45 am, oldyork90 <(E-Mail Removed)> wrote:
> On Jun 9, 5:43 pm, oldyork90 <(E-Mail Removed)> 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

>
> > 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
 
Reply With Quote
 
Thomas 'PointedEars' Lahn
Guest
Posts: n/a
 
      06-10-2008
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>
 
Reply With Quote
 
oldyork90
Guest
Posts: n/a
 
      06-10-2008
On Jun 9, 7:47 pm, RobG <(E-Mail Removed)> wrote:
> On Jun 10, 8:45 am, oldyork90 <(E-Mail Removed)> wrote:
>
> > On Jun 9, 5:43 pm, oldyork90 <(E-Mail Removed)> 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

>
> > > 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.
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
FWSM/PIX and Dynamic PAT using global IP range vs. global interface vs. global IP Hoffa Cisco 1 10-25-2006 06:50 PM
FWSM/PIX and Dynamic PAT using global IP range vs. global interface vs. global IP Hoffa Cisco 0 10-25-2006 01:04 PM
Could not load type 'Global.yaddayadda'. - Global.asax.cs Daniel Bass ASP .Net 2 12-31-2003 03:57 PM
Global variables on par with ASP's global.asa Wayne ASP .Net 2 11-11-2003 10:58 PM
Global Error handling in Applicatio_Error() of Global.asax VSK ASP .Net 1 07-29-2003 03:12 AM



Advertisments