May 20, 2003 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 |
Copyright © 1999-2021 by the D Language Foundation