On Thursday, 3 March 2022 at 20:23:14 UTC, forkit wrote:
>On Thursday, 3 March 2022 at 19:28:36 UTC, matheus wrote:
>I'm a simple man who uses D with the old C mentality:
[...]
string s, str = "4A0B1de!2C9~6";
foreach(i;str){
if(i < '0' || i > '9'){ continue; }
s ~= i;
}
[...]
mmm..but we no longer live in simple times ;-)
(i.e. unicode)
If you look here, you'll see that it's already the same logic. If it were me I would have even written like this:
"4A0B1de!2C9~6".filter!(c =>
'0' <= c && c <= '9'
).writeln; // 401296