Checking, whether string contains only ascii.
H. S. Teoh via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Wed Feb 22 13:23:45 PST 2017
On Wed, Feb 22, 2017 at 09:16:24PM +0000, kinke via Digitalmars-d-learn wrote:
[...]
> One more again as I couldn't believe noone went for 'any' yet:
>
> ---
> import std.algorithm;
> return !s.any!"a > 127"; // code-point level
> ---
You win 1 intarwebs for the shortest solution posted so far. ;-)
Though, according to the OP, an exception is wanted, so it should be
more along the lines of:
enforce(!s.any!"a > 127");
T
--
A bend in the road is not the end of the road unless you fail to make the turn. -- Brian White
More information about the Digitalmars-d-learn
mailing list