aboutsummaryrefslogtreecommitdiff
path: root/man/man3/tomo-Text.trim.3
blob: 13adf435f3963c2577ba2c295fc1d8bbfb42372e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
'\" t
.\" Copyright (c) 2025 Bruce Hill
.\" All rights reserved.
.\"
.TH Text.trim 3 2025-04-19T14:52:07.140723 "Tomo man-pages"
.SH NAME
Text.trim \- Trims the given characters (grapheme clusters) from the left and/or right side of the text.

.SH LIBRARY
Tomo Standard Library
.SH SYNOPSIS
.nf
.BI Text.trim\ :\ func(text:\ Text,\ to_trim:\ Text\ =\ "\ $\[rs]t\[rs]r\[rs]n",\ left:\ Bool\ =\ yes,\ right:\ Bool\ =\ yes\ ->\ Text)
.fi

.SH DESCRIPTION
Trims the given characters (grapheme clusters) from the left and/or right side of the text.


.TS
allbox;
lb lb lbx lb
l l l l.
Name	Type	Description	Default
text	Text	The text to be trimmed. 	-
to_trim	Text	The characters to remove from the left/right of the text. 	"\ $\[rs]t\[rs]r\[rs]n"
left	Bool	Whether or not to trim from the front of the text. 	yes
right	Bool	Whether or not to trim from the back of the text. 	yes
.TE
.SH RETURN
The text without the trim characters at either end.

.SH EXAMPLES
.EX
>> "   x y z    \[rs]n".trim()
= "x y z"

>> "one,".trim(",")
= "one"

>> "   xyz   ".trim(right=no)
= "xyz   "
.EE