Phobos: Arbitrary delimiter variants of (std.string) stripLeft and stripRight

Jonathan M Davis jmdavisProg at gmx.com
Sat Jun 23 17:25:16 PDT 2012


On Saturday, June 23, 2012 20:04:11 Chad J wrote:
> I'm not exactly sure what the arbitrary delimiter variants of stripLeft
> and stripRight are, but they should be referenced in the documentation
> of those functions.  And if they don't exist, why don't we have them?

There are no such variants. They could be added, but they don't currently 
exist.

> I was looking around for trimLeft and trimRight, but no luck.

trim and strip are the same thing. Having both would be bad design. It's 
understandable if you were looking for trim first, since a library could go 
with either name, and you probably have seen others using trim, but we chose 
strip, and we're not going to have both.

> chomp
> seems to be the arbitrary delimiter variant of trimRight, but then there
> is no chompLeft.

chompPrefix is chompLeft. And no, _neither_ is the delimiter variant of 
stripLeft or stripRight. stripRight with an arbitrary delimiter would remove 
all instances of that delimiter from the right-hand side of the array (and 
that delimiter would have to be a single character), whereas chomp takes a 
substring and removes _exactly_ that substring. The same would go for 
stripLeft and chompPrefix.

> If we had chompLeft I'd expect chompRight to exist and
> chomp to remove both the left and right parts.
> 
> There are also no examples/unittests in the documentation on the website
> for stripLeft, stripRight, chomp, or a bunch of others.

They could be added.

- Jonathan M Davis


More information about the Digitalmars-d mailing list