From: Toni Gundogdu Date: Tue, 11 Jun 2013 06:46:07 +0000 (+0300) Subject: quvi/util: Add escape_magic function X-Git-Tag: v0.9.20130619~3 X-Git-Url: https://repo.or.cz/w/libquvi-scripts.git/commitdiff_plain/751bf6dbd8c05c2ede518234fcccff889c3dfe1f quvi/util: Add escape_magic function Signed-off-by: Toni Gundogdu --- diff --git a/share/common/quvi/util.lua b/share/common/quvi/util.lua index 5641c43..b7d416f 100644 --- a/share/common/quvi/util.lua +++ b/share/common/quvi/util.lua @@ -146,6 +146,17 @@ function M.tokenize(s,sep) -- Based on http://lua-users.org/wiki/SplitJoin return fields end +--[[ +Escape Lua magic characters. +Parameters: + s .. String to escape +Returns + The escaped string. +]]-- +function M.escape_magic(s) + return (s:gsub('([()%%.%+%-*?[%]^$])', '%%%1')) +end + -- Uncomment to test --[[ package.path = package.path .. ';../?.lua'