• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 4180
  • Last Modified:

How to check if a string contains a number?

Hello,

I have a variable that is being set in coldfusion.  What I need to do is to somehow check If the variable contains numbers or only letters. So for example if the variable is HHIEU88HDKJS, I need something that know there are numbers in there and returns a value of True.  If the variable is NUUIENDIIE, I need it to return with false.


Thank you
0
Kamil0617
Asked:
Kamil0617
1 Solution
 
lostfocusCommented:
A regular expression may do the trick for you.
This may help explain it better.
http://www.seattlecfug.com/meetings/2006-11-02/RegEx.ppt
 
0
 
SidFishesCommented:
<cfset test = "aahjj">

<cfif refindnocase("[0-9]", test) neq 0>
      true
<cfelse>
      False
</cfif>
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now