summaryrefslogtreecommitdiffhomepage
path: root/tests/custom/03_stdlib/25_ltrim
blob: 2001322b8010213c618a6be27f3ca49a78b9c071 (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
44
45
46
The `ltrim()` function removes specific leading characters from the given
input string. If the characters to trim are unspecified, the space, tab,
carriage return and newline characters will be used by default.

Returns a copy of the input string with the specified leading characters
removed.

Returns `null` if the given input argment is not a valid string value.

-- Testcase --
{%
	printf("%.J\n", [
		// not specifying trim characters will trim whitespace
		ltrim(" 	Hello World!"),

		// if trim characters are specified, only those are removed
		ltrim("|* Foo Bar +|", "+*|"),

		// ltrim does not affect characters in the middle or the end
		ltrim("  Foo  Bar  "),
		ltrim("|Foo|Bar|", "|")
	]);
%}
-- End --

-- Expect stdout --
[
	"Hello World!",
	" Foo Bar +|",
	"Foo  Bar  ",
	"Foo|Bar|"
]
-- End --


Supplying an invalid string will yield `null`.

-- Testcase --
{%
	printf("%.J\n", ltrim(true));
%}
-- End --

-- Expect stdout --
null
-- End --