Closed Bug 291175 Opened 20 years ago Closed 20 years ago

exec method of regular expressions don't return the same result everytime executed

Categories

(Firefox :: General, defect)

x86
Windows 2000
defect
Not set
normal

Tracking

()

RESOLVED DUPLICATE of bug 98409

People

(Reporter: mgooijer, Assigned: bugzilla)

Details

User-Agent:       Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7.7) Gecko/20050414 Firefox/1.0.3
Build Identifier: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7.7) Gecko/20050414 Firefox/1.0.3

Adding /g modifier in a regular expression makes that when evaluating returns
different result (true/false) everytime executed. First time works ok, second
time the match fail. Another time works, another time fails ....
If page refreshed the problem doesn't appears.

Javascript Code pasted :
var sCode = 'Q2863008E';
var regular =/^[ABCDEFGHKLMNPQS, 0-9]{1}[0-9]{7}[A-J]{1}$/gi;
if (!regular.test(sCode)) {
    alert("wrong");
}

Reproducible: Always

Steps to Reproduce:
1.Create html page with javascript code
2.execute javascript code
3.

Actual Results:  
If page is not refreshed the script returns different result everytime executed

Expected Results:  
with the code avobe everytime true

*** This bug has been marked as a duplicate of 98409 ***
Status: UNCONFIRMED → RESOLVED
Closed: 20 years ago
Resolution: --- → DUPLICATE
You need to log in before you can comment on or make changes to this bug.