Ive tried that, however been a complete newbie to boost im probably
still
missing something obvious. Heres the test code so far
#include
#include <iostream> #include <string> #include using namespace std; int main (int argc, char *argv[]) { string uri ("slx://account/12345"); boost::regex re ("\\w+"); boost::cmatch what; if (boost::regex_match(uri.c_str(), what, re)) { cout << what[0] << endl; cout << what[1] << endl; cout << what[2] << endl; } else { cout << "nowt matched" << endl; } return 0; } It looks like there is some confusion about boost::regex_match does. It attempts to match the entire string against the regular expression (imagine an implicit ^ and $ around the expression).
I am not familiar with the C# library, but it looks like "Matches" finds all of the matches in the string and returns an array of them. Is this correct?
Yes thats correct.
If it is, then there are two things you can do:
Option 1: Change your expression to use captures. It might look like "slx://(\\w+)/(\\w+)". If you drop this ion your code above, you should see that what[0] is the entire uri, what[1] is "account" and what[2] is "12345". I generally prefer this method, as it also provides syntax checking.
This option worked perfectly. Thanks for the help Andrew.