M
Mokka
i need a check that can go through a string to see if it contains any
numbers.
Please help!
numbers.
Please help!
Mokka said:i need a check that can go through a string to see if it contains any
numbers.
RobG said:function hasNumbers(t)
{
return /\d/.test(t);
}
Returns true if t contains numbers, otherwise false.
function hasNumbers(t)
{
var regex = /\d/g;
return regex.test(t);
}
just try ~_~
If you do this a lot stretch the String.prototype:
String.prototype.gotNum=function(){
return /\d/.test(this)
}
otherwise
function gotNum(str){
return /\d/.test(str)
}
JRS: In article <Y9Cwf.1763$%W3.364@trndny07>, dated Mon, 9 Jan 2006
23:17:12 local, seen in mrHoo
If you do it, do it right. The test is for a digit, not for a number,
and should be named accordingly.
R2D2 & C3PO have digits in their names, but not numbers.
HM Queen Elizabeth II and William Gates III have a number in their IDs,
but no digits.
Dr John Stockton said the following on 1/10/2006 8:26 AM:
People can name functions anything they want. The fact that you disagree
with that naming convention is irrelevant to the code actually working.
JRS: In article <[email protected]>, dated Tue, 10 Jan
2006 14:35:40 local, seen in Randy Webb
First of October?
Surely, even if your software gets the date wring in the first place,
you can correct it manually?
Code should be written so that it can be correctly understood by the
literate, as well as the illiterate.
You'll just have to accept that handicap.
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.