我需要做一个简单的字符串拆分,但似乎没有一个函数可以做到这一点,而且我手动测试的方法似乎不起作用。我该怎么做呢?
发布于 2019-07-01 20:31:47
您可以使用penlight library。这有一个使用分隔符拆分字符串的功能,可以输出列表。
它实现了我们在编程时可能需要的许多函数,而Lua中缺少这些函数。
这是使用它的示例。
>
> stringx = require "pl.stringx"
>
> str = "welcome to the world of lua"
>
> arr = stringx.split(str, " ")
>
> arr
{welcome,to,the,world,of,lua}
>
https://stackoverflow.com/questions/1426954
复制相似问题