www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - regexp library and utf

It seems that the std.regexp module doesn't correctly handle non-ASCII text
and wildcard matching - or am I doing something wrong?

 import std.stdio;
 import std.regexp;
 import std.utf;
 void test(char[] sample, char[] pat)
 {
    int pos;
    validate(sample);
    validate(pat);
    writefln("sample = %s", cast(ubyte[])sample);
    pos = find(sample, pat);
    writefln("Where = %s %s", cast(ubyte[])pat, pos);
 }
 void main()
 {
    test("\u3026a\u2021\u5004b\u4011", "a\u2021\u5004b");
    test("\u3026a\u2021\u5004b\u4011", "a..b");

    test("1a23b4", "a23b");
    test("1a23b4", "a..b");

 }

This test fails when the pattern is "a..b" and the sample contains
non-ASCII text but works on all the other cases.

-- 
Derek
(skype: derek.j.parnell)
Melbourne, Australia
"Down with mediocrity!"
2/10/2006 11:20:28 AM
Oct 01 2006