From 751bf6dbd8c05c2ede518234fcccff889c3dfe1f Mon Sep 17 00:00:00 2001 From: Toni Gundogdu Date: Tue, 11 Jun 2013 09:46:07 +0300 Subject: [PATCH] quvi/util: Add escape_magic function Signed-off-by: Toni Gundogdu --- share/common/quvi/util.lua | 11 +++++++++++ 1 file changed, 11 insertions(+) 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' -- 2.11.4.GIT