Do we have a simple find/remove algorithm?
Adam D. Ruppe
destructionator at gmail.com
Sat Sep 26 12:46:25 UTC 2020
On Saturday, 26 September 2020 at 12:22:52 UTC, Andrei
Alexandrescu wrote:
> Removing one is oddly missing. I think we should add a
> findRemove algorithm. Question is, should it go in iteration.d
> or mutation.d? :o)
Something I often end up wanting in this is replace first
occurrence, and return the remainder.
So I have "abc" and you do replace a with ab, want:
result == "abbc"
remainder = "bc"
So then I can replace one and keep going without getting stuck in
a loop. I often do this myself with indexOf and slicing.
I guess it might be best to do it with findSplit but it would be
cool if a findAndReplaceFirst could return the remainder somehow
too.
More information about the Digitalmars-d
mailing list