helper: trimming whitespace from strings

This commit is contained in:
Kartik K. Agaram 2022-08-23 15:06:18 -07:00
parent aeaa7d150c
commit 43dfa184d6
1 changed files with 12 additions and 0 deletions

View File

@ -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