#include#include #include // point this to your Boost.Regex lib using namespace std; int main( ) { std::string s, sre; boost::regex re; while(true) { cout << "Expression: "; cin >> sre; if (sre == "quit") { break; } cout << "String: "; cin >> s; try { // Set up the regular expression for case-insensitivity re.assign(sre, boost::regex_constants::icase); } catch (boost::regex_error& e) { cout << sre << " is not a valid regular expression: \"" << e.what() << "\"" << endl; continue; } if (boost::regex_match(s, re)) { cout << re << " matches " << s << endl; } } }
petrichor (/'pe - tri - kor'/) is the familiar scent of rain on dry earth
this tech blog is the wafting fragrance of my geeky outpourings, one post at a time
Wednesday, May 27, 2009
c++: regular expression tester with boost
Labels:
C++,
programming,
regex
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment