gpt4 book ai didi

string - 返回具有负范围的 Lua string.sub()?

转载 作者:行者123 更新时间:2023-12-04 01:17:42 27 4
gpt4 key购买 nike

string.sub 的所有 Lua 定义中,当第二个索引为正但小于第一个时,我找不到它返回的内容。

例如string.sub(someString, 3, 2)

它总是返回空字符串“”吗?

最佳答案

是的。

引用:string.sub (s, i [, j]) :

If (...) i is greater than j, the function returns the empty string.

ij 分别是参数的第一个和第二个索引。

请注意,虽然 5.1 的手册 doesn't mention this behaviour (string.sub 的文档在 5.2 中得到了扩展),实现没有以有意义的方式改变:5.1 , 5.2 , 5.35.4 ;该行为在这些版本中是持久的。

关于string - 返回具有负范围的 Lua string.sub()?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63051664/

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