我需要打上原木和I've 好的工作reg,但现在我需要从编织档案中 set,这里是问题。
int logParser()
{
std::string bd_regex; // this reads from config in other part of program
boost::regex parsReg;
//("(C:.tmp.bd.*?)+(([a-zA-Z0-9_]+\.)+[a-zA-Z]{2,4})+(.+[a-zA-Z0-9_])");
try
{
parsReg.assign(bd_regex, boost::regex_constants::icase);
}
catch (boost::regex_error& e)
{
cout << bd_regex << " is not a valid regular expression: ""
<< e.what() << """ << endl;
}
cout << parsReg << endl;
// here it looks exactly like:
// "("(C:.tmp.bd.*?)+(([a-zA-Z0-9_]+\.)+[a-zA-Z]{2,4})+(.+[a-zA-Z0-9_])");"
int count=0;
ifstream in;
in.open(bd_log_path.c_str());
while (!in.eof())
{
in.getline(buf, BUFSIZE-1);
std::string s = buf;
boost::smatch m;
if (boost::regex_search(s, m, parsReg)) // it doesn t obey this "if"
{
std::string name, diagnosis;
name.assign(m[2]);
diagnosis.assign(m[4]);
strcpy(bd_scan_results[count].file_name, name.c_str());
strcpy(bd_scan_results[count].out, diagnosis.c_str());
strcat(bd_scan_results[count].out, " ");
count++;
}
}
return count;
}
我确实很想知道,为什么在我试图将其从混杂变量中确定下来时,同样的reg勤工作。
Any help will be appreciated (: