I'm trying to match a string who looks like:
/new-contact?id=nb&name=test
or /new-contact?id=nb
Basically the number of arguments is undefined.
so I have tried this regular expression:
boost::regex re("^/new-contact\\?(([a-zA-Z0-9_-]+)=([a-zA-Z0-9_-]+)&?)+$");
but when I try to use re with the following function:
function test()
{
std::string input("/new-contact?id=5&name=Test");
boost:cmatch token;
boost::regex_match(req.c_str(), token, input);
std::cout << token[1] << std::endl;
}
I get
output: name=Test
and if I change the input string to
std::string input("/new-contact?id=5&");
I get
output: id=5
I guess I am only getting the last token but I am suppose to get everything with the last "+" ?
What did I miss?
It's now working with:
^/new-contact\\?((([a-zA-Z0-9_-]+)=([a-zA-Z0-9_-]+)&?)+)$