How would one go about removing all letters from an input string leaving behind only numbers?
You could use string.gsub with a pattern to match all non-digits( %d matches digits, %D matches not-digits)
[lua]local s = "abc123def456"
local clean = s:gsub('%D','')
print(clean) --123456[/lua]
Are you referring to:
[lua]string.Replace( string, toReplace, replacer )[/lua]
I use it to take out the letters in SteamID and just leave the numbers, but it can be used for a lot of things.
For instance:
[lua]
local potato = "I am not Greg"
string.Replace( potato, "not", "really" )
returns "I am really Greg"
[/lua]
[QUOTE=wh1t3rabbit;41515059]You could use string.gsub with a pattern to match all non-digits( %d matches digits, %D matches not-digits)
[lua]local s = "abc123def456"
local clean = s:gsub('%D','')
print(clean) --123456[/lua][/QUOTE]
Thank you very much rabbit and MrGregsWorld
Sorry, you need to Log In to post a reply to this thread.