gpt4 book ai didi

lua - 字符串中字符的最后一个索引

转载 作者:行者123 更新时间:2023-12-01 22:20:55 24 4
gpt4 key购买 nike

如何在Lua中获取字符串中某个字符的最后一个索引?

"/some/path/to/some/file.txt"

如何获取上述字符串中最后一个 / 的索引?

最佳答案

index = string.find(your_string, "/[^/]*$")

(基本上,找到模式“正斜杠,然后零个或多个不是正斜杠的内容,然后是字符串末尾”出现的位置。)

关于lua - 字符串中字符的最后一个索引,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14554193/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com