Getting what came *before* the results of a find call
Ali Çehreli via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Fri Feb 27 14:42:17 PST 2015
On 02/27/2015 02:29 PM, Mark Isaacson wrote:
> What's the idiomatic way of getting everything *before* the results of a
> call to find?
>
> assert("hello world".find(" world").what_goes_here??? == "hello");
>
> In an article Andrei wrote a few years ago
> (http://www.informit.com/articles/article.aspx…) he mentioned a function
> like this with the name "until", but I can't find it or its replacement
> in Phobos.
findSplit and friends in std.algorithm:
import std.algorithm;
void main()
{
assert("hello world".findSplit(" world")[0] == "hello");
}
Ali
More information about the Digitalmars-d-learn
mailing list