can anyone please show me an example about using regex (regex.h) in C/C++ to search and/or extracting subpattern in a regex.
in javascript, it will be something like this,
var str = "the string contains 123 dots and 344 chars";
var r = /the string contains ([0-9].*?) dots and ([0-9].*?) chars/;
var res = r.exec(str);
var dots = res[1];
var chars = res[2];
alert('dots ' + dots + ' and chars ' + chars);
how can i do this using regex.h in c/c++ (not boost or any other libraries) ??
thanks,
There is no
regex.hin standard C or standard C++, so I’m assuming you mean the POSIX regular expression library. C example:(Add your own error checking. For more details, see this answer.)