On 16-Aug-11 10:22 AM, Jonathan M Davis wrote:
On Monday, August 15, 2011 14:28 Jonathan M Davis wrote:
On Monday, August 15, 2011 02:25 Joel Christensen wrote:
Ok, this is a good one I think.

import std.string, std.algorithm, std.functional;

bool isANum( dchar chr ) {
return inPattern( chr, digits ~ `"+-.` );
}

void main() {
auto input = `abc123`;
auto indexEnd = -1;

indexEnd = count!( not!isANum )( input );
assert( indexEnd == 3 );
}

Actually, it looks like count counts it for the whole range, not just how
many before it finds one which doesn't match. So, it's not quite what you
were looking for. I misread what it did.

The next release will have a version of countUntil that does what you want
though.

- Jonathan M Davis

Ok, good. Thanks Jonathan.

- Joel

Reply via email to