Bug 835 – RegExp.test wrongly matches strings on case insensitive attribute
Status
RESOLVED
Resolution
FIXED
Severity
major
Priority
P3
Component
phobos
Product
D
Version
D1 (retired)
Platform
x86
OS
Windows
Creation time
2007-01-12T22:20:00Z
Last change time
2014-02-15T13:12:59Z
Assigned to
bugzilla
Creator
tom_dlang
Comments
Comment #0 by tom_dlang — 2007-01-12T22:20:53Z
The following code describes the problem. I've noted also that [] in the regexp is determinant for the bug to show.
------------------------------------------------------------------
import std.regexp;
import std.stdio;
int main() {
auto str= "foo";
auto regex_str= r"fo[o]x";
auto regex= new RegExp(regex_str);
auto regex_i= new RegExp(regex_str, "i");
writefln("'%s' matches '%s' ? ", str, regex_str,
cast(bool) regex.test(str));
writefln("'%s' matches case insensitive '%s' ? ", str, regex_str,
cast(bool) regex_i.test(str));
return 0;
}
-------------------------------------------------------------------
The output is:
D:\src\d_tests>dmd -run bug_regexp.d
'foo' matches 'fo[o]x' ? false
'foo' matches case insensitive 'fo[o]x' ? true
Regards,
--
Tom;