New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Please add ltrim and rtrim to String #5589
Comments
Removed this from the M4 milestone. |
Would we want named args for trim? trim({bool trimLeft: true, bool trimRight: true}) To avoid member bloat? Removed this from the M5 milestone. |
I think I'd prefer separate methods. For names, I would prefer "trimLeft"/"trimRight". It's not as readable as "leftTrim"/"rightTrim", but not a lot worse, and it's much more discoverable. It'll be right next to "trim" in the API documentation. |
Agree with Lasse. |
Added Fixed label. |
This issue was originally filed by jjinux...@google.com
The String class has a trim method that trims both sides, but there's no method to trim just the left side or just the right side. Sometimes you need those, and they're really easy to implement using some code like this:
main() {
var start = " foo ";
var end = " foo ";
start = start.replaceFirst(new RegExp(r"^\s+"), ""); // ltrim
end = end.replaceFirst(new RegExp(r"\s+$"), ""); // rtrim
print("<$start>");
print("<$end>");
}
Dart Editor:
Version 0.1.0.201210010959, build 13075
Dart SDK version 13075
The text was updated successfully, but these errors were encountered: