[phobos] phobos commit, revision 2259
Andrei Alexandrescu
andrei at erdani.com
Mon Jan 3 07:45:28 PST 2011
On 1/3/11 7:56 AM, spir wrote:
> On Sun, 02 Jan 2011 23:33:45 -0600 Andrei
> Alexandrescu<andrei at erdani.com> wrote:
>
> [regex / regexp]
>
>> Which ones?
>
> According to the doc online, at least find/rfind/search are not
> there. (And count is in neither module.)
Let's see:
auto s = "abcabcabab";
auto result = find(s, RegExp("b"));
becomes:
auto s = "abcabcabab";
auto result = match(s, Regex("b")).pre.length;
They return different things on no match, but I think the latter is
better (pre returns the whole string on failure, which makes sense and
is easier to compose).
rfind has no simple equivalent so it should probably be added. On crazy
thought would be to have a primitive to reverse a Regex. Then you can
search the reversed string for the reversed regex.
search adds no functionality over match.
> By the way, maybe std.string.inPattern could be replaced by a true
> regex based func (also, it's currently rather slow from doing kind of
> hand-made match trial).
Yah, never liked inPattern.
Andrei
More information about the phobos
mailing list