Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

How can I get "string.gmatch(s, "%d+") do" to accept "-"?

How can I get:

for w in string.gmatch(s, "%d+") do

to accept "-" ? Right now it only accepts letters and numbers.

1 answer

%d only captures digits, for alphanumeric use %w
For negative numbers (while allowing positive aswell) -?%d+
For any string of numbers and/or -'s you can do [-%d]+

This discussion is preserved as it was. New answers, comments, and votes are closed.