【发布时间】:2014-05-19 03:09:03
【问题描述】:
如何在 Lua 中提取模式之间的文本。例如
s="this is a test string. <!2014-05-03 23:12:08!> something more"
- 我只需要日期/时间作为结果:
2014-05-03 23:12:08print(string.gsub(s, "%<!.-%!>"))不起作用 - 我需要所有没有日期/时间的文本,例如:
"this is a test string. something more"
【问题讨论】:
-
如果您可以确定文本中没有其他
<或>;使用%b匹配:s:gsub( '%b<>', '' )
标签: string lua lua-patterns