从字符串中提取最后一部分
我有一个字符串,如下所示:
local string = 'VALUE1_VALUE2_VALUE3_VALUE4'
我想仅使用 string.match 获取 VALUE4。我该怎么做?
I have a string, which looks like this:
local string = 'VALUE1_VALUE2_VALUE3_VALUE4'
I would like to get the VALUE4 only using string.match. How can i do this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这会匹配字符串末尾的 VALUE4
对于更通用的解决方案,您可以执行以下操作:
匹配字符串末尾的字母数字字符序列。
目前尚不清楚您实际上想做什么。但这应该给你一个起点。请参考Lua手册。
This matches VALUE4 at the end of a string
For a more general solution you can do something like this:
Match a sequence of alphanumeric characters at the end of your string.
It is not clear what you are actually trying to do. But this should give you a starting point. Please refer to the Lua manual.