Created
December 4, 2013 04:53
-
-
Save sylvanaar/7782554 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
MULTIBYTE_FIRST_CHAR = "^([\192-\255]?%a?[\128-\191]*)" | |
function GetNamePattern(name) | |
local u = name:match(MULTIBYTE_FIRST_CHAR):upper() | |
if not u or u:len() == 0 then Prat:Print("GetNamePattern: name error", name) return end | |
local l = u:lower() | |
local namepat | |
if u == l then | |
namepat = name:lower() | |
elseif u:len() == 1 then | |
namepat = "[" .. u .. l .. "]" .. name:sub(2):lower() | |
elseif u:len() > 1 then | |
namepat = "" | |
for i=1,u:len() do | |
namepat = namepat .. "[" .. u:sub(i, i) .. l:sub(i, i) .. "]" | |
end | |
namepat = namepat .. name:sub(u:len() + 1) | |
end | |
return "%f[%a\192-\255]" .. namepat .. "%f[^%a\128-\255]" | |
end | |
AnyNamePattern = "%f[%a\192-\255]([%a\128-\255]+)%f[^%a\128-\255]" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment