Dallime mes rishikimeve të "Moduli:string/charsetEscape"

Nga Enciklopedi Puro Shqiptare
Jump to navigation Jump to search
(Krijoi faqen me "local gsub = string.gsub local chars local function get_chars() chars, get_chars = { ["\000"] = "%z", ["%"] = "%%", ["-"] = "%-", ["]"] = "%]", ["^"] = "%^", }, nil return chars end --[==[Escapes the magic characters used in pattern character sets: {%-]^}, and converts the null character to {%z}.]==] return function(str) return (gsub(str, "[%z%%%-%]^]", chars or get_chars())) end")
 
(Pa ndryshime)

Versioni aktual i datës 10 gusht 2025 09:07

Udhëzuesi për këtë modul mund të krijohet te Moduli:string/charsetEscape/doc.

local gsub = string.gsub

local chars
local function get_chars()
	chars, get_chars = {
		["\000"] = "%z", ["%"] = "%%", ["-"] = "%-", ["]"] = "%]", ["^"] = "%^",
	}, nil
	return chars
end

--[==[Escapes the magic characters used in pattern character sets: {%-]^}, and converts the null character to {%z}.]==]
return function(str)
	return (gsub(str, "[%z%%%-%]^]", chars or get_chars()))
end