Thanks for the suggestion. I’ve added this for the next release: https://feedback.objo.dev/feature/734
String.Trim(), TrimStart(), and TrimEnd() now have overloads that accept a string containing the characters to remove:
Print("*#hello#*".Trim("*#")) # "hello"
Print("***hello***".TrimStart("*")) # "hello***"
Print("***hello***".TrimEnd("*")) # "***hello"
The supplied string is treated as a set of individual characters, not as a complete prefix or suffix.
I decided that supplying characters should replace the normal whitespace behaviour rather than add to it. This means Trim("*") removes only asterisks and does not silently remove whitespace. The existing parameterless methods continue to remove Unicode whitespace as before.
For the example in the original post, include both the space and asterisk:
Print(" ***WHEE!*** ".Trim(" *")) # "WHEE!"
Passing an empty string removes nothing:
Print(" hello ".Trim("")) # " hello "
The implementation also handles characters outside the Basic Multilingual Plane as complete Unicode code points.