Hello,

I would like to be able to make a regex from a text file :

[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);`));
    auto c = m.captures;

    writeln(c);

    return 0;
}
[/code]

But the main problem is that my file doesn't end with a semi colon ";". And so the regex cannot find anything in the file.

If I append this ";" at the end of my file, everything works as expected.

[code]
n=hello
[/code]
won't work whereas
[code]
n=hello;
[/code]
will.

Appending ";" with a mixin won't work either because it will create a new line.

Any idea ?

Thanks !

Larry

Reply via email to