[Issue 13632] New: Second argument for std.string.strip
via Digitalmars-d-bugs
digitalmars-d-bugs at puremagic.com
Sat Oct 18 03:42:46 PDT 2014
https://issues.dlang.org/show_bug.cgi?id=13632
Issue ID: 13632
Summary: Second argument for std.string.strip
Product: D
Version: D2
Hardware: x86
OS: Windows
Status: NEW
Severity: enhancement
Priority: P1
Component: Phobos
Assignee: nobody at puremagic.com
Reporter: bearophile_hugs at eml.cc
I suggest to add to std.string.strip a second optional argument as in the
Python string method strip:
str.strip([chars])
Return a copy of the string with the leading and trailing characters removed.
The chars argument is a string specifying the set of characters to be removed.
If omitted or None, the chars argument defaults to removing whitespace. The
chars argument is not a prefix or suffix; rather, all combinations of its
values are stripped:
Examples:
>>> ' spacious '.strip()
'spacious'
>>> "xxxdataxx".strip("x")
'data'
>>> 'www.example.com'.strip('cmowz.')
'example'
In D you can use a "char pattern" for the second argument.
--
More information about the Digitalmars-d-bugs
mailing list