• source navigation  • diff markup  • identifier search  • freetext search  • 

Sources/ucode/tests/custom/03_stdlib/25_ltrim

  1 The `ltrim()` function removes specific leading characters from the given
  2 input string. If the characters to trim are unspecified, the space, tab,
  3 carriage return and newline characters will be used by default.
  4 
  5 Returns a copy of the input string with the specified leading characters
  6 removed.
  7 
  8 Returns `null` if the given input argment is not a valid string value.
  9 
 10 -- Testcase --
 11 {%
 12         printf("%.J\n", [
 13                 // not specifying trim characters will trim whitespace
 14                 ltrim("         Hello World!"),
 15 
 16                 // if trim characters are specified, only those are removed
 17                 ltrim("|* Foo Bar +|", "+*|"),
 18 
 19                 // ltrim does not affect characters in the middle or the end
 20                 ltrim("  Foo  Bar  "),
 21                 ltrim("|Foo|Bar|", "|")
 22         ]);
 23 %}
 24 -- End --
 25 
 26 -- Expect stdout --
 27 [
 28         "Hello World!",
 29         " Foo Bar +|",
 30         "Foo  Bar  ",
 31         "Foo|Bar|"
 32 ]
 33 -- End --
 34 
 35 
 36 Supplying an invalid string will yield `null`.
 37 
 38 -- Testcase --
 39 {%
 40         printf("%.J\n", ltrim(true));
 41 %}
 42 -- End --
 43 
 44 -- Expect stdout --
 45 null
 46 -- End --

This page was automatically generated by LXR 0.3.1.  •  OpenWrt