Fast removal of character
Laeeth Isharc
laeeth at laeeth.com
Fri Oct 13 02:35:47 UTC 2017
On Wednesday, 11 October 2017 at 22:22:43 UTC, Johan Engelen
wrote:
> std.string.removechars is now deprecated.
> https://dlang.org/changelog/2.075.0.html#pattern-deprecate
>
> What is now the most efficient way to remove characters from a
> string, if only one type of character needs to be removed?
>
> ```
> // old
> auto old(string s) {
> return s.removechars(",").to!int;
> }
>
> // new?
> auto newnew(string s) {
> return s.filter!(a => a != ',').to!int;
> }
> ```
>
> cheers,
> Johan
There's always this:
https://github.com/dlang/undeaD/blob/master/src/undead/string.d
More information about the Digitalmars-d-learn
mailing list