Module:Sandbox/Melvintong1516/Names

local p = {}

p.givenname = function(frame) local name = frame.args.name local nameformat = frame.args.nameformat or "en" if nameformat == "en" then local enposofblank1, enposofblank2 = string.find(name, "(%s)%a+(%s)") if enposofbalnk1 == nil then enposofblank1 = string.find(name, "(%s)%a+") end if enposofblank2 ~= nil then local givenname = string.sub(name, 1, enposofblank2) return givenname else local givenname = string.sub(name, 1, enposofblank1) return givenname end end if nameformat == "de" then local deposofblank1 = string.find(name, "(%s)%a+") local givenname = string.sub(name, 1, deposofblank1) return givenname end end

p.famname = function(frame) local name = frame.args.name local nameformat = frame.args.nameformat or "en" if nameformat == "en" then local enposofblank1, enposofblank2= string.find(name, "(%s)%a+(%s)") if enposofblank2 ~= nil then local enendspace = string.find(name, "(%s)%a+", -enposofblank1) if enendspace ~= nil and enendspace ~= enposofblank2 then local famname = string.sub(name, enposofblank2, enendspace) return famname else local famname = string.sub(name, enposofblank2) return famname end else if enposofblank1 == nil then enposofblank1 = string.find(name, "(%s)%a+") local famname = string.sub(name, enposofblank1) return famname end end end if nameformat == "de" then local deposofblank1, deposofblank2 = string.find(name, "(%s)van(%s)" or "(%s)den(%s)" or "(%s)Broek(%s)" or "(%s)de(%s)" or "(%s)de Jesús(%s)" or "(%s)%a+(%s)") if deposofblank1 == nil then deposofblank1 = string.find(name, "(%s)%a+") end if deposofblank2 ~= nil then if string.find(string.sub(name, deposofblank1), string.sub(name, deposofblank2)) == string.sub(name, deposofblank1, deposofblank2) then famname = string.sub(name, deposofblank1) return famname else local famname = string.sub(name, deposofblank2) return famname end else local famname = string.sub(name, deposofblank1) return famname end end end

p.test = function(frame) local name = frame.args.name local nameformat = frame.args.nameformat or "en" if nameformat == "de" then local deposofblank1, deposofblank2= string.find(name, "(%s)%a+(%s)") if deposofblank2 ~= nil then local deendspace = string.find(name, "(%s)%a+í%a%s%a+)", -deposofblank2)			if deendspace ~= nil			then local famname = string.sub(name, deendspace)				return famname .. "endspace"			else local famname = string.sub(name, deposofblank2)				return famname .. "2"			end		else if deposofblank1 == nil			then deposofblank1 = string.find(name, "(%s)%a+")				local famname = string.sub(name, deposofblank1)				return famname .. "1"			end		end	end end

return p