lua - 在lua中查找两个字符串之间的字符串
问题描述
我一直在尝试在 2 个字符串之间找到所有可能的字符串
这是我的输入:"print/// to be able to put any amount of strings here endprint///"
目标是打印介于两者之间的每个print///
字符串endprint///
解决方案
您可以使用Lua 的字符串模式来实现这一点。
local text = "print/// to be able to put any amount of strings here endprint///"
print(text:match("print///(.*)endprint///"))
该模式捕获介于和之间的"print///(.*)endprint///"
任何字符"print///"
"endprint///"
推荐阅读
- python - 使用 Python 运行宏后如何保存 Excel 工作簿?
- knockout.js - 使用来自 knockoutjs $data 对象的值作为索引
- nltk - 斯坦福 NER 标记器和 NLTK - 不工作 [OSError: Java 命令失败]
- visual-studio-code - 不仅在类似 css 的范围内启用 vscode 颜色选择器
- python - 如何使用 __import__ 导入类而不是模块
- ios - ReactNative TextInput 值不会在 IOS 上更新
- r - survcomp 包:找不到函数“hazard.ratio”
- spring-boot - 如何解决 Okta 应用程序问题?
- azure-devops - VSTS 中围绕 PAT 的控制和治理
- mysql - 如何在 mysql 中使用 SUM() 进行计数?