在go中使用lua示例, 基于gopher-lua!
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

30 lines
646 B

4 years ago
  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. ```