From 43dfa184d6e63e17efcd0c20a1090632eba88141 Mon Sep 17 00:00:00 2001 From: "Kartik K. Agaram" Date: Tue, 23 Aug 2022 15:06:18 -0700 Subject: helper: trimming whitespace from strings --- text.lua | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/text.lua b/text.lua index 6f76442..61ead17 100644 --- a/text.lua +++ b/text.lua @@ -990,3 +990,15 @@ function Text.clear_screen_line_cache(State, line_index) State.line_cache[line_index].fragments = nil State.line_cache[line_index].screen_line_starting_pos = nil end + +function trim(s) + return s:gsub('^%s+', ''):gsub('%s+$', '') +end + +function ltrim(s) + return s:gsub('^%s+', '') +end + +function rtrim(s) + return s:gsub('%s+$', '') +end -- cgit 1.4.1-2-gfad0 name='h' onchange='this.form.submit();'> Soul of a tiny new machine. More thorough tests → More comprehensible and rewrite-friendly software → More resilient society.Kartik K. Agaram <vc@akkartik.com>
about summary refs log blame commit diff stats
path: root/html/081print.mu.html
blob: b6d2bd96d1bc0eb597594f880e86fcd73ce8e61f (plain) (tree)
1
2
3
4
5
6
7
8
9
10