我希望能用某种方法使用lua隔离以下字符串中的数字98和7,525.07。
“我可以确认今天事件总文件已经上传。共有98起事件共计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+"
)
答案 0 :(得分:4)
如果第一个值只有数字字符,则可以使用此匹配:
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%.%,]+)") )