1 The `rtrim()` function removes specific trailing 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 trailing 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 rtrim("Hello World! \r \n"), 15 16 // if trim characters are specified, only those are removed 17 rtrim("|* Foo Bar +|", "+*|"), 18 19 // rtrim does not affect characters in the middle or the beginning 20 rtrim(" Foo Bar "), 21 rtrim("|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