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


Hello,

 

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 |

 
boost::regex_constants::match_single_line;

 

      // 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.

 

Regards,

Anurag

 


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk