royale-compiler icon indicating copy to clipboard operation
royale-compiler copied to clipboard

Invalid Regex Flag x

Open yishayw opened this issue 5 years ago • 3 comments

  •                           var regex : RegExp = /[\s*]+/gx;
    
  •                           var regex : RegExp = /[\s*]+/g;
    

The x flag is legal in AS3 but not in js, so the first line should probably yield be a compile time error.

yishayw avatar Oct 27 '20 15:10 yishayw

I thought I remember the x is rewritten?

Harbs avatar Oct 27 '20 16:10 Harbs

Not in what I saw... I'll try to come up with a test case when I find the time.

yishayw avatar Oct 27 '20 19:10 yishayw

new RegExp("a | b", "gx")

produces this runtime error:

Uncaught SyntaxError: invalid regular expression flag x

The x is extended syntax, to allow spaces to be in the expression for readability purposes. The spaces are ignored, unless preceded by a backslash (\).

estanglerbm avatar Dec 14 '20 14:12 estanglerbm