Boost logo

Boost :

Subject: [boost] boost::regex problem with escaped parenthesis
From: Kumar, Anurag (Anurag.Kumar_at_[hidden])
Date: 2008-12-01 08:39:46



While trying to match the escaped "(" I am facing problem. Following is
the code snippet :


      std::string stdString = "abc(def)ghi";

      std::string bExpression = "c\\(def\\)g";


      // Creating the expression

      boost::regex boostRegEx ( bExpression, boost::regex::extended );


      // my match function

      boost::smatch boostMatch;


      std::string::const_iterator itr_begin ( stdString.std().begin());

      std::string::const_iterator itr_end ( stdString.std().end() );


      bool b_match = false;

      // Match flags used

      boost::match_flag_type matchFlags =
boost::regex_constants::match_default |

boost::regex_constants::match_not_dot_newline |



      // Trying to match

      b_match = boost::regex_search( itr_begin, itr_end, boostMatch,
boostRegEx, matchFlags );


My expected result is:

b_match should be "true"

boostMatch should contain "c(def)g"


Please help me to fix this problem.





Boost list run by bdawes at, gregod at, cpdaniel at, john at