Meinhoonaa
asked on
how to extract numbers from string using Javascript?
how to extract numbers from string using Javascript?
Test cases below:
string s = 1AA11111
string s1= 2111CA2
string s result = 111111
string s1 result = 211112
My code below is not working:
var j = 0;
var startPlateNums = "";
while (j <= iStartLength && !isNaN(iStartNumber.substr ing(j, j + 1)))
{
startPlateNums = startPlateNums + iStartNumber.substring(j, j + 1);
j++;
}
Test cases below:
string s = 1AA11111
string s1= 2111CA2
string s result = 111111
string s1 result = 211112
My code below is not working:
var j = 0;
var startPlateNums = "";
while (j <= iStartLength && !isNaN(iStartNumber.substr
{
startPlateNums = startPlateNums + iStartNumber.substring(j, j + 1);
j++;
}
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
or this simple regular expression:
Open in new window
Sample:
http://jsfiddle.net/EE_RainerJ/3FyXJ/
HTH
Rainer