New issue
Advanced search Search tips

Issue 842392 link

Starred by 1 user

Issue metadata

Status: WontFix
Owner: ----
Closed: May 2018
Cc:
Components:
EstimatedDays: ----
NextAction: ----
OS: Linux , Windows , Mac
Pri: 2
Type: Bug



Sign in to add a comment

Unpredictable regexp results when saving regex to a variable and calling 'exec()'

Reported by matthew....@gmail.com, May 12 2018

Issue description

UserAgent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/66.0.3359.139 Safari/537.36

Steps to reproduce the problem:
1. In any console, enter:

let property = 'salary_rules[nil36378820000][description]'

2. Then enter:

let idRegex = /^salary_rules\[(.*?)\]\[(title|description)\]/g;

3. Now enter the following repeatedly:

idRegex.exec(property)

What is the expected behavior?
A match is returned each time.

What went wrong?
A match is returned every other time, even though neither the regex nor the string is changing.

Did this work before? N/A 

Chrome version: 66.0.3359.139  Channel: n/a
OS Version: OS X 10.12.6
Flash Version:
 

Comment 1 by woxxom@gmail.com, May 12 2018

This is working correctly as per the specification. Your regexp is global which makes exec iterate and return the matches, then return null when there are no more matches. You can set idRegex.lastIndex = 0 before invoking exec to always start at the beginning of the input string.
Labels: Needs-Triage-M66
Cc: vamshi.kommuri@chromium.org
Labels: M-68 Triaged-ET FoundIn-68 Target-68 OS-Linux OS-Windows
Status: Untriaged (was: Unconfirmed)
Thanks for filing the issue!

Able to reproduce the issue on reported chrome version 66.0.3359.139 and on the latest canary 68.0.3430.0 using Mac 10.13.1, Ubuntu 14.04 and Windows 10. As the issue is seen from M60(60.0.3112.0) considering it as Non-Regression and marking it as Untriaged.

Comment 4 by kojii@chromium.org, May 16 2018

Status: WontFix (was: Untriaged)
Closing as per comment #1.

Sign in to add a comment