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

RESOLVED DUPLICATE of bug 98409

Status

()

Firefox
General
RESOLVED DUPLICATE of bug 98409
11 years ago
11 years ago

People

(Reporter: RonJonk, Unassigned)

Tracking

2.0 Branch
PowerPC
Mac OS X
Points:
---

Firefox Tracking Flags

(Not tracked)

Details

(URL)

(Reporter)

Description

11 years ago
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
(Reporter)

Updated

11 years ago
Version: unspecified → 2.0 Branch
Status: UNCONFIRMED → RESOLVED
Last Resolved: 11 years ago
Resolution: --- → DUPLICATE
Duplicate of bug: 98409
You need to log in before you can comment on or make changes to this bug.