? kills IE Mac

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

    ? kills IE Mac

    I have a script with a regex

    var re = /\/(\w+?)\//;

    In IE5 Mac, that kills all javascript, anywhere on the page. No errors
    but no functionality at all. Just the mere presence of that line without
    it being called.

    removing the "?", returns everything normal.

    var re = /\/(\w+)\//;

    Why could that be?

    Is the default regex behaviour non greedy and the "?" really uneeded?

    Cheers,
    Jeff
  • Michael Winter

    #2
    Re: ? kills IE Mac

    On Sat, 25 Dec 2004 00:07:22 GMT, Jeff Thies <jeff@spamalana dingong.com>
    wrote:
    [color=blue]
    > I have a script with a regex
    >
    > var re = /\/(\w+?)\//;
    >
    > In IE5 Mac, that kills all javascript, anywhere on the page.[/color]

    As I understand it, versions of IE prior to 6 don't support non-greedy
    matching. Microsoft's documentation isn't specific about this and I don't
    have access to earlier versions, so I could be wrong.

    [snip]
    [color=blue]
    > Is the default regex behaviour non greedy and the "?" really uneeded?[/color]

    The default is greedy matching, but it doesn't matter here. The two
    slashes can't be matched as part of the \w character class.

    Mike

    --
    Michael Winter
    Replace ".invalid" with ".uk" to reply by e-mail.

    Comment

    • Martin Honnen

      #3
      Re: ? kills IE Mac



      Jeff Thies wrote:
      [color=blue]
      > I have a script with a regex
      >
      > var re = /\/(\w+?)\//;
      >
      > In IE5 Mac, that kills all javascript, anywhere on the page. No errors
      > but no functionality at all. Just the mere presence of that line without
      > it being called.
      >
      > removing the "?", returns everything normal.[/color]
      [color=blue]
      > Why could that be?[/color]

      Browsers implemented regular expressions in JavaScript before the
      ECMAScript edition 3 standardized them so in browsers like Netscape 4 or
      IE 5/Mac or IE 5/Windows (in the standard installation, on Windows it is
      possible to update the JScript engine without changin the IE version)
      you find regular expression support but not with all the features
      standardized in ECMAScript edition 3. The non-greedy matching with '?'
      placed after a quantifier is one of the features that those older
      browsers do not support so IE 5/Mac probably chokes on that regular
      expression syntax and that way stops executing the script. That it kills
      all JavaScript sounds unlikely, if there are several <script> blocks in
      a page an error in one should not kill execution of the other script
      blocks. But I am not too familiar with IE 5 on the Mac.

      --

      Martin Honnen

      Comment

      Working...