evilgeniuz
July 6th, 2011, 06:53 PM
Hello everyone!
I'm trying to know closer boost::regex library and i've got some problems with it. :confused:
I've found some example just to test works or not.
int find_data()
{
std::string xStr("The boost library has a great opportunity for the regex!");
boost::regex xRegEx("\\b(?:\\w+?)((\\w)\\2)(?:\\w+?)\\b");
boost::smatch xResults;
std::cout << "\n==========================Results=============== ===============\n";
std::string::const_iterator xItStart = xStr.begin();
std::string::const_iterator xItEnd = xStr.end();
while( boost::regex_search(xItStart, xItEnd, xResults, xRegEx) )
{
std::cout << "Word, we've searched, is \"" << xResults[0] << "\". It has two \"" << xResults[2] << "\" inside itself.\n";
xItStart = xResults[1].second;
}
return 1;
}
it must result
==========================Results================= =============
Word, we've searched, is «boost». It has two «o» inside itself.
Word, we've searched, is «opportunity». It has two «p» inside itself.
buuuuuuuuuuuuuut it reults....
==========================Results================= =============
parser: /usr/local/inluce/boost/smart_ptr/shared_ptr.hpp:412 boost::shared_ptr<T>::reference boost::shared_ptr<T>::operator*() const [with T = boost::regex_traits_wrapper<boost::regex_traits<char> >, boost::shared_ptr<T>::reference = boost::regex_traits_wrapper<boost::regex_traits<char> >&>: Assertion `px !=0' failed.
Aborted
So, i'm using ubuntu 11.04, code::blocks and installed boost::regexp from repository. Help me please.
I'm trying to know closer boost::regex library and i've got some problems with it. :confused:
I've found some example just to test works or not.
int find_data()
{
std::string xStr("The boost library has a great opportunity for the regex!");
boost::regex xRegEx("\\b(?:\\w+?)((\\w)\\2)(?:\\w+?)\\b");
boost::smatch xResults;
std::cout << "\n==========================Results=============== ===============\n";
std::string::const_iterator xItStart = xStr.begin();
std::string::const_iterator xItEnd = xStr.end();
while( boost::regex_search(xItStart, xItEnd, xResults, xRegEx) )
{
std::cout << "Word, we've searched, is \"" << xResults[0] << "\". It has two \"" << xResults[2] << "\" inside itself.\n";
xItStart = xResults[1].second;
}
return 1;
}
it must result
==========================Results================= =============
Word, we've searched, is «boost». It has two «o» inside itself.
Word, we've searched, is «opportunity». It has two «p» inside itself.
buuuuuuuuuuuuuut it reults....
==========================Results================= =============
parser: /usr/local/inluce/boost/smart_ptr/shared_ptr.hpp:412 boost::shared_ptr<T>::reference boost::shared_ptr<T>::operator*() const [with T = boost::regex_traits_wrapper<boost::regex_traits<char> >, boost::shared_ptr<T>::reference = boost::regex_traits_wrapper<boost::regex_traits<char> >&>: Assertion `px !=0' failed.
Aborted
So, i'm using ubuntu 11.04, code::blocks and installed boost::regexp from repository. Help me please.