mirror of
https://github.com/TangentFoxy/lume.git
synced 2024-11-19 07:04:24 +00:00
Fixed use of pattern special chars in lume.trim()
Using lua pattern special chars in the `chars` argument of lume.trim() are now handled correctly and treated like any other character.
This commit is contained in:
parent
d69f419f5a
commit
ad64d7af05
3
lume.lua
3
lume.lua
@ -288,7 +288,8 @@ end
|
|||||||
|
|
||||||
|
|
||||||
function lume.trim(str, chars)
|
function lume.trim(str, chars)
|
||||||
chars = chars or "%s"
|
if not chars then return str:match("^[%s]*(.-)[%s]*$") end
|
||||||
|
chars = chars:gsub("[%(%)%.%%%+%-%*%?%[%]%^%$]", "%%%1")
|
||||||
return str:match("^[" .. chars .. "]*(.-)[" .. chars .. "]*$")
|
return str:match("^[" .. chars .. "]*(.-)[" .. chars .. "]*$")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user