Lua string.find语句问题

s,e=string.find("hello Lua users","Lua")
print(s,e)

结果为7 9

在manual里看,也没有看懂。为什么会是7,9?
* 附:

string.find (s, pattern [, init [, plain]])

Looks for the first match of pattern in the string s. If it finds a match, then > find returns the indices of s where this occurrence starts and ends; otherwise, it returns nil. A third, optional numerical argument init specifies where to start the search; its default value is 1 and can be negative. A value of true as a fourth, optional argument plain turns off the pattern matching facilities, so the function does a plain "find substring" operation, with no characters in pattern being considered magic. Note that if plain is given, then init must be given as well.

If the pattern has captures, then in a successful match the captured values are also returned, after the two indices.

阅读 6.1k
1 个回答

突然发现自己蠢了一下,已知道答案。

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进