digitalmars.D.learn - Types of regex
- Larry (29/29) Jul 15 2013 Hello,
- Simen Kjaeraas (18/47) Jul 15 2013 Have you tried iterating over m? This works for me:
- Larry (6/6) Jul 15 2013 Humm,
- Dmitry Olshansky (4/10) Jul 15 2013 It looks like a _very_ old GDC. What's you version string/OS/package ?
- Larry (2/2) Jul 15 2013 I have gdc 4.6 on Debian testing.
- H. S. Teoh (9/12) Jul 16 2013 That is extremely old. You want to get gdc-4.8.1 from unstable, if you
- Larry (5/5) Jul 16 2013 AAAh !!
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
Jul 15 2013
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 ! LarryHave 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
Jul 15 2013
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 !
Jul 15 2013
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
Jul 15 2013
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.
Jul 16 2013
AAAh !! Got it ! I will make the switch ! Thanks a lot :) Larry
Jul 16 2013