#include #include // strlen #include #include int main() { static boost::regex re("^\\s*(\\S+)"); // My RE boost::smatch match; std::string comm = "abcd"; // the input string if(boost::regex_search(comm, match, re)) { comm = match.suffix(); // eat the matched word std::string word(match.str(1)); // get the matched word assert(strlen(word.c_str()) > 0); // ASSERTION FAILS!!! // "word" should be "abcd", gdb output: // (gdb) p word // $1 = "\000bcd" } }