Is str ~ regex the root of all evil, or the leaf of all good?
Andrei Alexandrescu
SeeWebsiteForEmail at erdani.org
Thu Feb 19 10:18:05 PST 2009
BCS wrote:
> Reply to bearophile,
>
>> Michel Fortin:
>>
>>> foreach(e; "co" in "conoco")
>>> writeln(e);
>>> should work too.
>> Of course :-) I think eventually it will work, it's handy and natural.
>>
>>> By the way, regular expressions should work everywhere where we can
>>> search for a string. For instance (from std.string):
>>> auto firstMatchIndex = find("conoco", "co");
>>> should work with a regex too:
>>> auto firstMatchIndex = find("abracazoo", regex("a[b-e]", "g"));
>> I agree, I have said the same thing regarding splitter()/xsplitter().
>>
>> Bye,
>> bearophile
>
> If the overhead of regex(string) is small enough (vs having it in the
> find/split function) I'd go with overloads rather than different names.
The overhead is low because the last few used regexes are cached.
Andrei
More information about the Digitalmars-d
mailing list