Boost logo

Boost Users :

From: sugi_at_[hidden]
Date: 2003-03-06 08:27:11


Hi. I found some strange behaviors in Regex++.
For details, please see the following source.
These are bugs? or do I have mistaken?
boost's version is 1.29.0.

---
#include <iostream>
#include <boost/regex.hpp>
using namespace std;
void p(const char *r, const char *s){
    cout << endl << "*********" << endl;
    cout << "regex: " << r << endl;
    cout << "string: " << s << endl;
    cout << "result: " << 
	(boost::RegEx(r).Search(s) ? "found" : "not found") << endl;
}
int main(){
    
    // I think this must not match, but this do.
    p("a\\Z", "a\nb");
    
    // These match. Correct behaviors.    
    p("()", "abc");
    p("^()", "abc");
    p("^()+", "abc");
    p("^(){1}", "abc");
    // But these don't match.
    // Are these wrong?
    p("^(){2}", "abc");
    p("^((){2})", "abc");
    
    // I feel these somewhat strange.
    // But I have little confidence to say that this is a bug.
    p("()", "");        // found (OK)
    p("()\\1", "");     // not found (this must match?)
    p("()\\1", "a");    // found (OK)
    p("a()\\1b", "ab"); // found (OK)
    p("a()b\\1", "ab"); // not found (this must match?)
    return 0;
}
---
Kouhei Yanagita

Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net