I want to use string.find to get any string that is any 4 digits, then a space, and another 4 digits (example: "6969 6969"). I've tried "%d%d%d%d %d%d%d%d" and "%d%d%d%d%s%d%d%d%d" and also "%d%d%d%d".." ".."%d%d%d%d" and nothings worked. Someone please help, thanks.
Try using string.match
.
string.match
will search through a string for a pattern (second argument), and return the first matching substring if one is found
http://robloxdev.com/articles/string-patterns-reference
Pattern you want:
"%d%d%d%d%s%d%d%d%d"
Example of how this works:
local pattern = "%d%d%d%d%s%d%d%d%d" local string = "7394 1027" local match = string.match(string,pattern) print(match)
Output: 7394 1027
Your pattern was missing the whitespace character class, %s
.