我需要一个特殊的Lua模式,该模式接受字符串中所有大写字母,并用空格和相应的小写字母替换它们;
TestStringOne => test string one
this isA TestString => this is a test string
能做到吗
假设仅使用ASCII,则可以这样做:
function lowercase(str)
return (str:gsub("%u", function(c) return ' ' .. c:lower() end))
end
print(lowercase("TestStringOne"))
print(lowercase("this isA TestString"))
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句