D2: std.algorithm.find, but get part before what you were searching for
Jonathan M Davis
jmdavisProg at gmail.com
Thu Mar 4 12:33:58 PST 2010
Jesse Phillips wrote:
> Jonathan M Davis wrote:
>
>> Hmm. I'd thought that I'd looked at that one and determined that it
>> didn't do what I was looking for, but on another inspection of it, it
>> does look like until() will do the job. It has the potential downside
>> that unlike find, it cannot take multiple ranges to be found, but in my
>> case (and probably most cases), that's not an issue. Thanks. Maybe this
>> is what I get for coding late at night...
>
>
> You should be able to use std.range.chain to combine your ranges.
I don't think that that would work. As I understand it, with find, when you
give it call it with more than two values
e.g. find(haystack, needle1, needle2, needle3) instead of
find(haystack, needle)
it looks for all of those values and returns when it finds one of them. All
combining ranges would do for until would make a longer thing to find. In
essence, you'd be doing
find(haystack, needle1 ~ needle2 ~ needle3)
only with until. Finding all of the values concatenated together is not the
same thing as looking for the first occurrence of one of those values.
- Jonathan M Davis
More information about the Digitalmars-d-learn
mailing list