【发布时间】:2018-01-01 20:19:43
【问题描述】:
我想从一个字符串中提取一个特定的值。这是我的字符串
iptables -t nat -A PREROUTING -p tcp -m tcp --dport 666 -j DNAT --to-destination 192.168.19.55
如何在 lua 中使用 string.match 从该字符串中提取192.168.19.55 ip 地址?
我完成了local ip = s:match("--to-destination (%d+.%d+.%d+.%d+)")),但我没有得到值 192.168.19.55 。我得到空值。
这有什么错误吗?有什么建议 ?
【问题讨论】:
-
你需要使用
%-转义-,这是Lua模式中的一个魔术字符。
标签: string lua lua-patterns