--- In Boost-Users@yahoogroups.com, "aitors2002"
Hello, the next program doesn't work. It should print all the lines except the ones starting with '#'. It does work in perl : $ perl -ne 'print unless /^\s*\#/' a.cc
why ?
Thank you aitor
------------------- // a.cc #include<iostream> #include<fstream> #include<string> #include<vector> #include
int main() {
using namespace std;
ifstream f("a.cc"); string l; vector<string> v; static const boost::regex r("^\\s*\\#", boost::regbase::escape_in_lists | boost::regbase::perl);
while(f) { getline(f,l,'\n'); if (boost::regex_match(l,r)) continue; v.push_back(l); } for(vector<string>::const_iterator it = v.begin(); it != v.end(); ++it) cout << *it << endl; }
Hello again, the problem was because of using regex_match instead of regex_search, since regex_match requires that the whole string matches. Thank you for the help aitor