Reputation: 111
I am trying to convert the matched string into a int using regex/boost.
I used this C++ to convert Boost Regex match result to other format as a reference. However when I tried I got expected primary-expression before ‘int’
and Symbol 'lexical_cast' could not be resolved
error.
this is my code:
#include <iostream>
#include <string>
#include <boost/regex.hpp>
using namespace std;
using namespace boost;
int main(){
string a = "123";
boost::regex e("123");
boost::smatch match;
if (boost::regex_search(a, match, e))
{
int number = boost::lexical_cast<int>(match[0]);
cout << number << endl;
}
return 0;
}
why am I getting these errors?
Upvotes: 2
Views: 415