generic image
Processing...
  • Games
  • Catalog
  • Develop
  • Robux
  • Search in Players
  • Search in Games
  • Search in Catalog
  • Search in Groups
  • Search in Library
  • Log In
  • Sign Up
  • Games
  • Catalog
  • Develop
  • Robux
   
ROBLOX Forum » Game Creation and Development » Scripting Helpers
Home Search
 

Re: How to check if a String contains only Numbers?

Previous Thread :: Next Thread 
dylanbuider is not online. dylanbuider
Joined: 14 Jun 2008
Total Posts: 17141
16 Nov 2014 02:47 PM
Help, please?
Report Abuse
lordrambo is not online. lordrambo
Joined: 16 Jun 2009
Total Posts: 20628
16 Nov 2014 02:49 PM
if tonumber(string) then
end
Report Abuse
Xsitsu is online. Xsitsu
Joined: 28 Jul 2009
Total Posts: 2921
16 Nov 2014 02:57 PM
local string = "This is my string"
for v in string.gmatch(string, "%D") do
     print("Non numeric character found!")
end

This code will check the string against a certain pattern to see if there are any matches within it. For every match that is found, the code within the loop will run.
This bit of code will check for any character that is not a numeric character within the string. For every character it finds, it will print that it has found it.

I should probably also mention that whitespace characters count as not being numeric characters.

You should be able to use code structured somewhat like this to get the results you want.

You may want to read up on this wiki article for more information on patterns:
http://wiki.roblox.com/index.php?title=Patterns
Report Abuse
dylanbuider is not online. dylanbuider
Joined: 14 Jun 2008
Total Posts: 17141
16 Nov 2014 03:18 PM
That helps, thanks
Report Abuse
JarodOfOrbiter is not online. JarodOfOrbiter
Joined: 17 Feb 2011
Total Posts: 20029
16 Nov 2014 03:20 PM
if String:match("%d") == String then
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripting Helpers
   
 
   
  • About Us
  • Jobs
  • Blog
  • Parents
  • Help
  • Terms
  • Privacy

©2017 Roblox Corporation. Roblox, the Roblox logo, Robux, Bloxy, and Powering Imagination are among our registered and unregistered trademarks in the U.S. and other countries.



Progress
Starting Roblox...
Connecting to Players...
R R

Roblox is now loading. Get ready to play!

R R

You're moments away from getting into the game!

Click here for help

Check Remember my choice and click Launch Application in the dialog box above to join games faster in the future!

Gameplay sponsored by:
Loading 0% - Starting game...
Get more with Builders Club! Join Builders Club
Choose Your Avatar
I have an account
generic image