从字符串中提取各种字符(备用方法)

好的,我有一些混淆的文本字符串,我想从字符串中提取小写字符、大写字符和数字值到三个子字符串中,以后用于我的目的。我当前有这样的代码:

sInput = "AWSEDRGY VGIYCfry2345ewScfvg gyiFvyGXSCyuI^RSfv GYD&K^dfyUODvl234SDv8p7ogYHS"
local sLower, sUpper, sNumbers = "", "", ""
sInput:gsub("%l", function(s)  sLower=sLower..s end)
sInput:gsub("%u", function(s)  sUpper=sUpper..s end)
sInput:gsub("%d", function(s)  sNumbers=sNumbers..tostring(s) end)
print( sLower, sUpper, sNumbers )

这很好地运作着。我只是不确定在使用这三个单独的提取函数处理近30,000行混淆文本时会不会更有效率呢?还是我的方法已经是最好的方案了?

点赞
用户107090
用户107090

尝试使用 _补集类_:

sInput = "AWSEDRGY VGIYCfry2345ewScfvg gyiFvyGXSCyuI^RSfv GYD&K^dfyUODvl234SDv8p7ogYHS"
local sLower = sInput:gsub("%L","")
local sUpper = sInput:gsub("%U","")
local sNumbers = sInput:gsub("%D","")
print( sLower, sUpper, sNumbers )
2012-06-27 10:52:07