Reputation: 397
I wish for some way to isolate the numbers 98 and 7,525.07 in the following string using lua.
"I can confirm todays incident total file has been uploaded. There are 98 incidents totalling 7,525.07"
What would be the best way to accomplish this?
I have this which picks up the first number, but I'm struggling on picking up the second figure
number = string.match(
"I can confirm todays incident total file has been uploaded. There are 98 incidents totalling 7,525.07",
"%d+"
)
Upvotes: 2
Views: 419
Reputation: 2205
if first value only numeric chars you can use this match:
local s = "I can confirm todays incident total file has been uploaded. There are 98 incidents totalling 7,525.07"
print (s:match(".-(%d+).-([%d%.%,]+)") )
Upvotes: 4