www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 13632] New: Second argument for std.string.strip

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 puremagic.com
          Reporter: bearophile_hugs 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. --
Oct 18 2014