www.digitalmars.com Home | Search | C & C++ | D | DMDScript | News Groups | index | prev | next
Archives

D Programming
D
D.gnu
digitalmars.D
digitalmars.D.bugs
digitalmars.D.dtl
digitalmars.D.dwt
digitalmars.D.announce
digitalmars.D.learn
digitalmars.D.debugger

C/C++ Programming
c++
c++.announce
c++.atl
c++.beta
c++.chat
c++.command-line
c++.dos
c++.dos.16-bits
c++.dos.32-bits
c++.idde
c++.mfc
c++.rtl
c++.stl
c++.stl.hp
c++.stl.port
c++.stl.sgi
c++.stlsoft
c++.windows
c++.windows.16-bits
c++.windows.32-bits
c++.wxwindows

digitalmars.empire
digitalmars.DMDScript

c++ - RegExp bug?

It seems that case-insensitive regular expressions become case sensitive
after a literal '.' in the pattern. Below is a test program compiled
with DMC version 8.33 and a sample run. Note that every test string
should match but uppercase chars after the '.' cause no match.

**** test program ****
// retest.cpp - RegExp test
// argv[1] is pattern
// search for pattern in argv[2..argc-1]

#include <iostream.h>
#include <regexp.h>
#include <assert.h>

main(int argc, char *argv[])
{
    assert(argc>2);
    RegExp re;
    assert(re.compile(argv[1],"i",1));    // "i" = case insensitive
    for (int j=2; j<argc; ++j) {
        cout << argv[j];
        if (re.test(argv[j]))
            cout << " match " << re.pmatch[0].rm_so << ' ' <<
re.pmatch[0].rm_eo << '\n';
        else
            cout << " no match\n";
    }
}


**** sample run ****
**** (note . after \  in some fonts it is hard to see) ****
C:\dm\temp> retest  a\.b  A.b a.B  A.B  a.b
A.b  match 0 3
a.B  no match
A.B  no match
a.b  match 0 3
May 19 2003