digitalmars.D.bugs - [Issue 11536] New: split optional maxsplit argument
- d-bugmail puremagic.com (29/39) Nov 17 2013 https://d.puremagic.com/issues/show_bug.cgi?id=11536
https://d.puremagic.com/issues/show_bug.cgi?id=11536 Summary: split optional maxsplit argument Product: D Version: D2 Platform: All OS/Version: All Status: NEW Severity: enhancement Priority: P2 Component: Phobos AssignedTo: nobody puremagic.com ReportedBy: bearophile_hugs eml.cc In Python str.split method has an optional argument (named maxsplit), the number of times to split: http://docs.python.org/2/library/stdtypes.html#str.split['5', 'red', 'blue']"5 red blue".split()['5', ' red blue']"5 red blue".split(" ", 1)['5', 'red blue']"5 red blue".split(None, 1)['red', 'blue', '10']"red blue 10".rsplit()['red blue ', '10']"red blue 10".rsplit(" ", 1)['red blue', '10'] It's handy when you have a not uniform string that you want to split partially:"red blue 10".rsplit(None, 1)'20't = "20 Walter Bright" n, name = t.split(None, 1) n'Walter Bright' I think such optional argument could be useful in Phobos split as well. -- Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------name
Nov 17 2013