Open
Description
Dart should have methods that are able to remove specified leading and trailing parts of a string. I propose using strip
and it's associates, stripLeft
and stripRight
to keep in line with trim
.
"@bar".stripLeft('@'); // "bar"
"bar@".stripRight('@'); // "bar"
"@bar@".strip('@'); // "bar"
"@@bar".stripLeft('@'); // "bar"
"@@bar".stripLeft('@@'); // "bar"
"@@bar".stripLeft('@@@'); // "@@bar"
"@@@bar".stripLeft('@@'); // "@bar"
The signature for the methods would be:
String strip(String pattern) {} // Only String, see lrhn's comment about matching backwards with RegEx
String stripLeft(Pattern pattern) {}
String stripRight(String string) {} // Only String, see lrhn's comment about matching backwards with RegEx