我有这个字符串
"Hello there, this is some line-aa."
如何将其切片成这样的数组?
Hello
there,
this
is
some
line-aa.
这是我到目前为止所尝试过的
function sliceSpaces(arg)
local list = {}
for k in arg:gmatch("%w+") do
print(k)
table.insert(list, k)
end
return list
end
local sentence = "مرحبا يا اخوتي"
print("sliceSpaces")
print(sliceSpaces(sentence))
此代码适用于英文文本,但不适用于阿拉伯语,我怎样才能使其也适用于阿拉伯语?
Lua 字符串是字节序列,而不是 Unicode 字符。图案%w
匹配字母数字字符,但仅适用于 ASCII。
相反,使用%S
匹配非空白字符:
for k in arg:gmatch("%S+") do
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)