首页 > 解决方案 > 在lua中查找两个字符串之间的字符串

问题描述

我一直在尝试在 2 个字符串之间找到所有可能的字符串

这是我的输入:"print/// to be able to put any amount of strings here endprint///"

目标是打印介于两者之间的每个print///字符串endprint///

标签: lua

解决方案


您可以使用Lua 的字符串模式来实现这一点。

local text = "print/// to be able to put any amount of strings here   endprint///"

print(text:match("print///(.*)endprint///"))

该模式捕获介于和之间的"print///(.*)endprint///"任何字符"print///""endprint///"


推荐阅读