|
Boost Users : |
Subject: [Boost-users] [Regex] Search Substring
From: S Nagre (snagre.mumbai_at_[hidden])
Date: 2011-03-08 09:21:29
Hi,
I am new to boost Libraries and I am trying to find a substring using
Boost::Regex
Lets say I want to find string "Hello" in "Hello world".
std::string completeStr = "Hello World";
std::string::const_iterator startOffset = completeStr.begin();
std::string::const_iterator endOffset = completeStr.end();
std::string searchWord= "Hello";
boost::regex expression(searchWord);
boost::match_flag_type flags = boost::match_any;
while(boost::regex_search(startOffset, endOffset, what, expression, flags))
{
int32 position = what.position(1);
int32 len = what[1].length();
}
but value of this position and length value is coming out to be -1.
It is not able to find this substring, Could anyone tell me what I am doing
wrong ?
Subhash
Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net