473,698 Members | 2,554 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

check if string contains any numbers

i need a check that can go through a string to see if it contains any
numbers.

Please help!

Jan 7 '06
12 78713
Dr John Stockton said the following on 1/10/2006 8:26 AM:
JRS: In article <Y9Cwf.1763$%W3 .364@trndny07>, dated Mon, 9 Jan 2006
23:17:12 local, seen in news:comp.lang. javascript, mrHoo
<dr***@yankeewe b.com> posted :
If you do this a lot stretch the String.prototyp e:

String.protot ype.gotNum=func tion(){
return /\d/.test(this)
}
otherwise
function gotNum(str){
return /\d/.test(str)
}

If you do it, do it right. The test is for a digit, not for a number,
and should be named accordingly.


People can name functions anything they want. The fact that you disagree
with that naming convention is irrelevant to the code actually working.
R2D2 & C3PO have digits in their names, but not numbers.
Actually, they do. The name is R-Two-D-Two which contains two numbers.
C3PO has the Number Three in its name.
HM Queen Elizabeth II and William Gates III have a number in their IDs,
but no digits.


Well Duh.

--
Randy
comp.lang.javas cript FAQ - http://jibbering.com/faq & newsgroup weekly
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
Jan 10 '06 #11
JRS: In article <ft************ ********@comcas t.com>, dated Tue, 10 Jan
2006 14:35:40 local, seen in news:comp.lang. javascript, Randy Webb
<Hi************ @aol.com> posted :
Dr John Stockton said the following on 1/10/2006 8:26 AM:


First of October? Surely, even if your software gets the date wring in
the first place, you can correct it manually?
If you do it, do it right. The test is for a digit, not for a number,
and should be named accordingly.


People can name functions anything they want. The fact that you disagree
with that naming convention is irrelevant to the code actually working.


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.

--
© John Stockton, Surrey, UK. ?@merlyn.demon. co.uk Turnpike v4.00 MIME. ©
Web <URL:http://www.merlyn.demo n.co.uk/> - w. FAQish topics, links, acronyms
PAS EXE etc : <URL:http://www.merlyn.demo n.co.uk/programs/> - see 00index.htm
Dates - miscdate.htm moredate.htm js-dates.htm pas-time.htm critdate.htm etc.
Jan 11 '06 #12
Dr John Stockton said the following on 1/11/2006 9:05 AM:
JRS: In article <ft************ ********@comcas t.com>, dated Tue, 10 Jan
2006 14:35:40 local, seen in news:comp.lang. javascript, Randy Webb
<Hi************ @aol.com> posted :
Dr John Stockton said the following on 1/10/2006 8:26 AM:

First of October?


Where is there anything above that says October? Even you, in all your
infamously glorious ignorance surely wouldn't read a post on the 10th
day of January and read the date as October the First? The only two word
phrase that can appropriately describe that behavior is: pedantic idiot.
With the emphasis on idiot.
Surely, even if your software gets the date wring in the first place,
you can correct it manually?
How do you wring a date?

wring: to squeeze or twist especially so as to make dry or to extract
moisture or liquid

I am unaware that a date contains any moisture or liquid to extract.

Check your spell checker, it seems to be broken. And from someone who
self proclaims to compose off line, connect and then post you should
endeavor to check your spelling. Especially if you wish to be as
pedantic as you are at times.

Anyway, if my software had gotten the date wrong, then surely I could
have corrected it. But since it got it right there was no reason to
correct it. Manually or programatically .
If you do it, do it right. The test is for a digit, not for a number,
and should be named accordingly.
People can name functions anything they want. The fact that you disagree
with that naming convention is irrelevant to the code actually working.

Code should be written so that it can be correctly understood by the
literate, as well as the illiterate.


There was nothing to be mis-understood about that code. Well, other than
your pedantic ignorance about the meaningless name of a function. It
could well have been named myHumptyDumptyF unction and the code would
have remained the same. Other than it didn't satisfy your ignorant
pedantic desires of a name for that function.

You'll just have to accept that handicap.


I don't have a problem with any handicap you have, I am pleased to see
you finally admit to having one though.

--
Randy
comp.lang.javas cript FAQ - http://jibbering.com/faq & newsgroup weekly
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
Jan 11 '06 #13

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
1171
by: Chris Michael | last post by:
I've got a string of numbers, say 123456 (the actually number is 12 digits long). I need to calculate the sum of each individual number in the string of numbers, so in the example of 123456 the sum would be 21 (1+2+3+4+5+6). Thanks
5
13850
by: ief | last post by:
hi all, i'm trying to check the length of a numeric value in a string. this is what i need to do: I have a string "Mystring (253)" and a string "SecondString (31548745754)" Now i have to check if the string contains more than 3 numeric characters because i must only process the ones with more than 3.
4
36742
by: Merlin | last post by:
Hi there, I would like to check if a string is a valid zip code via Javascript. Length and existents are already checked. How can I find out if the string contains characters other than numbers? Example: 834F7 schould be false since it countains an F character
9
11230
by: booksnore | last post by:
I am writing some code to search for strings that contain every letter of the alphabet. At the moment I am using the method below to check to see if a string contains every letter of the alphabet. I wanted to use a regular expression but I could not find an ‘AND’ operator within the regular expression – so I need something like match true if string contains ‘a’ and ‘b’ and ‘c’ and ‘d’ ..etc,etc. If anyone has any thoughts on how I can...
1
3160
by: Lala | last post by:
Hi, I need to check if a string contains unicode characters, and generate an alert if it does. (I do not want to parse the string to unicode). Anyone who knows how to do this? Thanks! :D
13
14977
by: nishit.gupta | last post by:
Is their any fuction available in C++ that can determine that a string contains a numeric value. The value cabn be in hex, int, float. i.e. "1256" , "123.566" , "0xffff" Thnx
14
2925
by: nishit.gupta | last post by:
Is their any single fuction available in C++ that can determine that a string contains a numeric value. The value cabn be in hex, int, float. i.e. "1256" , "123.566" , "0xffff" , It can also contain zero
4
10272
by: Jeff | last post by:
Hey ..NET 3.5 I'm trying to search a string to determine if the string contains </table>, but string.Contains don't find it. I've used WebRequest/WebReponse to retrieve the html from a webpage and now I'm searching through this html... this webpage contains 4 html tables. so there are 4 </table>, but my code don't find any...
2
12880
by: gamernaveen | last post by:
I wanted to include a string invalid character check in my application. Like the field comment , if a user inserts any special characters (Except '' , '@' , '/' , '=' and numbers - alphabets) , the function should return true , if the string contains no special char in any position , the function should return false. Can anyone design a function to check the special chars ? Thanks so much.
0
8685
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8612
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9032
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8905
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8880
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7743
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6532
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5869
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
3053
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.