std.string.indexOf with an optional start-at parameter?
Andrei Alexandrescu
SeeWebsiteForEmail at erdani.org
Sun Apr 3 11:16:54 PDT 2011
On 4/3/11 1:14 PM, Aleksandar Ružičić wrote:
> I thought first of slicing, but isn't that making a copy of string?
It's not.
> And also, if I'm not mistaken if you slice out of range bounds (i.e.
> haystack[5..$] when haystack.length< 5) you'll get exception, right?
Correct.
> That's why I think this would be nice to have feature, so you don't
> have to worry if start position is within the string bounds, and you
> won't need to write this:
I think that's a natural and simple improvement of indexOf. The one
aspect that I'm unsure about is starting from the end for negative indices.
Could you please submit an enhancement request to bugzilla?
Andrei
More information about the Digitalmars-d
mailing list