【问题标题】:How i can do this with lua? (preg_match() in php)我怎么能用lua做到这一点? (php 中的 preg_match())
【发布时间】:2019-07-13 13:21:42
【问题描述】:

我需要关于 lua 中 preg_match 的帮助,我尝试了一些不同的方法。

我尝试使用string.matchstring.find,但无法正确编写模式。

我在php中知道这种方式,但在lua中需要类似的方式

$s = "/testas [51]";
preg_match("#/testas [(.*)]#", $s, $out);
print_r($out);

我想在[ ] 中获取一个整数。

【问题讨论】:

标签: lua


【解决方案1】:

要获取 [ ] 内的整数,请尝试以下代码:

print(string.match(s,"/testas%s+%[(%d+)%]"))

模式直接来自任务规范。我们只需要转义括号。

【讨论】:

  • 是的,但我需要 /testas 一起,检查日志 ant 如果机器人会找到 /testas [int] 他只会得到 88
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2022-11-09
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2019-06-01
  • 1970-01-01
相关资源
最近更新 更多