Closed Bug 418408 Opened 18 years ago Closed 18 years ago

testing a string for a numeric value with regular expression returns alternate true and false

Categories

(Firefox :: General, defect)

2.0 Branch
PowerPC
macOS
defect
Not set
normal

Tracking

()

RESOLVED DUPLICATE of bug 98409

People

(Reporter: bugzilla, Unassigned)

References

()

Details

User-Agent: Mozilla/5.0 (Macintosh; U; Intel Mac OS X; en-US; rv:1.8.1.12) Gecko/20080201 Firefox/2.0.0.12 Build Identifier: Mozilla/5.0 (Macintosh; U; Intel Mac OS X; en-US; rv:1.8.1.12) Gecko/20080201 Firefox/2.0.0.12 Using the regular expression /[\D]/g or [^0-9] in javascript it returns false if testing for instance string "3a" but when I execute the test the second time it returns true. This result alternates true and false for every time I execute this test expression. Reproducible: Always Steps to Reproduce: 1. create test expression: function isNumeric(str){ var re = /[\D]/g if (re.test(str)) alert('false'); else alert('true'); } 2.execute script with string nonnumeric for instance '3a' 3.execute it a second time Actual Results: alerts true ,alerts false, alerts true ,alerts false, etc.. Expected Results: should always alert false
Version: unspecified → 2.0 Branch
Status: UNCONFIRMED → RESOLVED
Closed: 18 years ago
Resolution: --- → DUPLICATE
You need to log in before you can comment on or make changes to this bug.