Types of regex

Larry deco33 at hotmail.fr
Mon Jul 15 02:32:52 PDT 2013


Hello,

I read the library reference for regex.

I really miss python's equivalent of finditer.

Sometimes matching is not on purpose and one will want to match 
all the occurences to iterate over it since it is much more 
regarding concerning the orders and repetitions.


my code :
-----------------------------------------------------------------------------
version(Tango) extern (C) int printf(char *, ...);

import std.stdio;
import std.regex;
import std.file;
import std.format;

int main(char[][] args)
{
     string fl = readText("testregexd.txt");

     auto m = match(fl, regex(`(<n=(?:hello|goodbye))*`,"g"));
     auto c = m.captures;

     writeln(c);

     return 0;
}

---------------------------------------------------------------------------

Content of testregexd.txt:
----------------------------------------------------------------------------

<n=hello <n=goodbye

----------------------------------------------------------------------------

Any way to workaround ?

Thanks !

Larry


More information about the Digitalmars-d-learn mailing list