Module:string/php trim

Wiktionary වෙතින්

Lua equivalent of PHP's trim($string), which trims "\0", "\t", "\n", "\v", "\r" and " ". This is useful when dealing with template parameters, since the native parser trims them like this.


local find = string.find
local match = string.match

-- Note: PHP does not trim \f but does trim \0.
return function(text)
	local n = find(text, "[^%z\t-\v\r ]")
	return n and match(text, ".*[^%z\t-\v\r ]", n) or ""
end
"https://si.wiktionary.org/w/index.php?title=Module:string/php_trim&oldid=164323" වෙතින් සම්ප්‍රවේශනය කෙරිණි