[phobos] phobos commit, revision 2259

spir denis.spir at gmail.com
Mon Jan 3 08:26:30 PST 2011


On Mon, 03 Jan 2011 09:45:28 -0600
Andrei Alexandrescu <andrei at erdani.com> wrote:

> 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).

Right, hadn't explored enough to get that. (Finally used an alternative, did not need regexes anymore.)

> 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.

Agreed.

> > 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.

I'l have a look when I have time.
 
> Andrei

Denis
-- -- -- -- -- -- --
vit esse estrany ☣

spir.wikidot.com



More information about the phobos mailing list