diff options
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/string.fnl | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/lib/string.fnl b/lib/string.fnl index 3e6134e..c722bd3 100644 --- a/lib/string.fnl +++ b/lib/string.fnl @@ -32,8 +32,9 @@ (fn ends-with [str end] (= (string.sub str (- (# end))) end)) -(fn trim [str] - (str:match "^%s*(.-)%s*$")) +(fn trim [str pattern] + (local pattern (or pattern "%s")) + (str:match (.. "^" pattern "*(.-)" pattern "*$"))) (fn truncate [str len ellipsis] (if (and (= (type str) "string") |
