I am trying the C++ standard regex library. But it is throwing std::regex_error exception. No idea what is going wrong. I can use Boost regex or PCRE also.
But I thought of going with G++ provided regex module. But unable to make it work with even simple expressions. Don't worry about the unused variables, I started with a moderately complex expression which needed them. But now I have reduced it just to match a word.
Please check sample which is crashing here:
#include <iostream>
#include <stdio.h>
#include <regex>
int main()
{
const char *vals = "abcdef";
unsigned long start;
unsigned int off;
unsigned int size;
std::cmatch cr;
std::regex rx("(\\w+)");
std::regex_match(vals, cr, rx);
std::cmatch::iterator it = cr.begin();
while (it != cr.end()){
std::cout << *it << std::endl;
++it;
}
return 0;
}