From a0d092090da33c5e0e7760bccf3d4ff56cb4e581 Mon Sep 17 00:00:00 2001 From: Lars Mueller Date: Fri, 23 Sep 2022 12:06:12 +0200 Subject: [PATCH] Remove text.trim[_*] funcs except for trim_spacing --- text.lua | 44 -------------------------------------------- 1 file changed, 44 deletions(-) diff --git a/text.lua b/text.lua index 0546d26..62cd9ad 100644 --- a/text.lua +++ b/text.lua @@ -17,50 +17,6 @@ function contains(str, substr, plain) return not not str:find(substr, 1, plain == nil and true or plain) end -function trim(text, to_remove) - local j = 1 - for i = 1, string.len(text) do - if text:sub(i, i) ~= to_remove then - j = i - break - end - end - local k = 1 - for i = string.len(text), j, -1 do - if text:sub(i, i) ~= to_remove then - k = i - break - end - end - return text:sub(j, k) -end - -function trim_begin(text, to_remove) - local j = 1 - for i = 1, string.len(text) do - if text:sub(i, i) ~= to_remove then - j = i - break - end - end - return text:sub(j) -end - -trim_left = trim_begin - -function trim_end(text, to_remove) - local k = 1 - for i = string.len(text), 1, -1 do - if text:sub(i, i) ~= to_remove then - k = i - break - end - end - return text:sub(1, k) -end - -trim_right = trim_end - function trim_spacing(text) return text:match"^%s*(.-)%s*$" end