在go中使用lua示例, 基于gopher-lua!
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

30 行
646 B

4 年前
  1. # strings
  2. origin code: https://github.com/vadv/gopher-lua-libs/tree/master/strings
  3. ## Usage
  4. ```lua
  5. local strings = require("strings")
  6. -- strings.split(string, sep)
  7. local result = strings.split("a b c d", " ")
  8. -- Output: { "a", "b", "c", "d" }
  9. -- strings.has_prefix(string, prefix)
  10. local result = strings.has_prefix("abcd", "a")
  11. -- Output: true
  12. -- strings.has_suffix(string, suffix)
  13. local result = strings.has_suffix("abcd", "d")
  14. -- Output: true
  15. -- strings.trim(string, cutset)
  16. local result = strings.trim("abcd", "d")
  17. -- Output: abc
  18. -- strings.contains(string, substring)
  19. local result = strings.contains("abcd", "d")
  20. -- Output: true
  21. ```