在go中使用lua示例, 基于gopher-lua!
No puede seleccionar más de 25 temas Los temas deben comenzar con una letra o número, pueden incluir guiones ('-') y pueden tener hasta 35 caracteres de largo.

30 líneas
646 B

hace 4 años
  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. ```