regx, global efficiencies?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • oldyork90

    regx, global efficiencies?

    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.

  • oldyork90

    #2
    Re: regx, global efficiencies?

    On Jun 9, 5:43 pm, oldyork90 <oldyor...@yaho o.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);

    Comment

    • RobG

      #3
      Re: regx, global efficiencies?

      On Jun 10, 8:45 am, oldyork90 <oldyor...@yaho o.comwrote:
      On Jun 9, 5:43 pm, oldyork90 <oldyor...@yaho o.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

      Comment

      • Thomas 'PointedEars' Lahn

        #4
        Re: regx, global efficiencies?

        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>

        Comment

        • oldyork90

          #5
          Re: regx, global efficiencies?

          On Jun 9, 7:47 pm, RobG <rg...@iinet.ne t.auwrote:
          On Jun 10, 8:45 am, oldyork90 <oldyor...@yaho o.comwrote:
          >
          On Jun 9, 5:43 pm, oldyork90 <oldyor...@yaho o.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.

          Comment

          Working...