regexp library and utf
Derek Parnell
derek at nomail.afraid.org
Sun Oct 1 18:40:31 PDT 2006
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
More information about the Digitalmars-d-learn
mailing list