在字符串 lua 中查找两个数字
Finding two numbers in a string lua
我希望有一些方法可以使用 lua.
来隔离以下字符串中的数字 98 和 7,525.07
"I can confirm todays incident total file has been uploaded. There are 98 incidents totalling 7,525.07"
完成此任务的最佳方法是什么?
我有这个可以提取第一个数字,但我很难提取第二个数字
number = string.match(
"I can confirm todays incident total file has been uploaded. There are 98 incidents totalling 7,525.07",
"%d+"
)
如果第一个值只有数字字符,您可以使用此匹配:
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%.%,]+)") )
我希望有一些方法可以使用 lua.
来隔离以下字符串中的数字 98 和 7,525.07"I can confirm todays incident total file has been uploaded. There are 98 incidents totalling 7,525.07"
完成此任务的最佳方法是什么?
我有这个可以提取第一个数字,但我很难提取第二个数字
number = string.match(
"I can confirm todays incident total file has been uploaded. There are 98 incidents totalling 7,525.07",
"%d+"
)
如果第一个值只有数字字符,您可以使用此匹配:
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%.%,]+)") )