ExtendScript regular expression matching bug

  • 2
  • Problem
  • Updated 6 years ago
In ExtendScript, regular expression matching appears to have a bug.

This expression: "a_bs".match(/^\s*(A)(?:_B|_BS)?\s*$/i)
Evaluates to: a_bs,

It should evaluate to: a_bs, a
If I add another group it appears to work.

This expression: "a_bs".match(/^\s*((A)(?:_B|_BS)?)\s*$/i)
Evaluates to: a_bs,a_bs,a

Please fix this.
Photo of Adrian Bentley

Adrian Bentley

  • 2 Posts
  • 0 Reply Likes
  • frustrated

Posted 6 years ago

  • 2
Photo of Adrian Bentley

Adrian Bentley

  • 2 Posts
  • 0 Reply Likes
Oh I'm seeing this behavior in CS5.
Photo of David Jensen

David Jensen

  • 131 Posts
  • 46 Reply Likes
"a_bs".match(/^\s*(A)(?:_B|_BS)?\s*$/i)

Also, if you remove the second asterisk, it will crash.