string.rstrip
Returns str with white-space characters removed from the end only.
Parameters
str | string | the string to trim |
Return value
A new string with the trailing white space removed; leading white space, if any, is kept.
Notes
See strip for exactly which characters count as white space.
Example
from "string" import rstrip
println("rstrip(\" hi \") =", $"[{rstrip(" hi ")}]")
// nothing at the back to strip: the string comes back unchanged
println("rstrip(\"hi\") =", $"[{rstrip("hi")}]")Output:
rstrip(" hi ") = [ hi]
rstrip("hi") = [hi]See also
strip | Returns str with white-space characters removed from both ends. |
lstrip | Returns str with white-space characters removed from the beginning only. |
| string | module index |