Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

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

Asked by
ItsMeKlc 235 Moderation Voter
9 years ago

How can I get:

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

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

1 answer

Log in to vote
0
Answered by 9 years ago

%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]+

Ad

Answer this question