Re: Types of regex

2013-07-16 Thread Larry

I have gdc 4.6 on Debian testing.

Is that so old ?


Re: Types of regex

2013-07-16 Thread H. S. Teoh
On Tue, Jul 16, 2013 at 08:15:16AM +0200, Larry wrote:
 I have gdc 4.6 on Debian testing.
 
 Is that so old ?

That is extremely old. You want to get gdc-4.8.1 from unstable, if you
can. A great number of bugs have been fixed since gdc-4.6; in fact, the
entire std.regex has been replaced, which is probably why you're seeing
these problems with regexes that the rest of us don't see.


T

-- 
If it's green, it's biology, If it stinks, it's chemistry, If it has
numbers it's math, If it doesn't work, it's technology.


Types of regex

2013-07-15 Thread Larry

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


Re: Types of regex

2013-07-15 Thread Simen Kjaeraas

On 2013-07-15, 11:32, Larry wrote:


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


Have you tried iterating over m? This works for me:

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

int main(char[][] args)
{
string fl = 
n=hello n=goodbye
;

auto m = match(fl, regex(`(n=(?:hello|goodbye))`,g));
foreach (c; m)
writeln(c);

return 0;
}

--
Simen


Re: Types of regex

2013-07-15 Thread Larry

Humm,

A copy-paste of your code lead to :

[[segmentation 
fault


So it doesn't work for me.

I use gdc if it might help !


Re: Types of regex

2013-07-15 Thread Dmitry Olshansky

15-Jul-2013 14:21, Larry пишет:

Humm,

A copy-paste of your code lead to :

[[segmentation
fault

So it doesn't work for me.

I use gdc if it might help !


It looks like a _very_ old GDC. What's you version string/OS/package ?

--
Dmitry Olshansky