Hi All, I have a string in the following form: w="id = 10" C=field1 G=GeoRaster X=leMHG08wViX2quWNB All I want is to iterator onto the key/values pairs. w "id = 10" C field1 G GeoRaster X leMHG08wViX2quWNB The key/value pairs are separated by spaces. However, I can not simply use a space pattern to iterate over my input string since the W option allows the user to use "" to include spaces. Can someone tell me what is wrong in the following code? oParametersValue represents my input string. regex eParam("(.)=(\"?.*\"?)", regex::normal | regbase::icase); int const sub_matches[] = { 1, 2 }; // key, value sregex_token_iterator oIter(oParametersValue.begin(), oParametersValue.end(), eParam, sub_matches); sregex_token_iterator j; while (oIter != j) { std::cout << *oIter++ << std::endl; } Thanks
On Thu, 06 Apr 2006 10:32:05 +0100, John Maddock wrote:
regex eParam("(.)=(\"?.*\"?)", regex::normal | regbase::icase);
The .* is greedy so it gobbles up all remaining input including spaces and quotes.
How about:
(.)=((?:\"[^\"]*\")|(?:[^[:space:]]*))
John.
Hi, I just noticed that I posted the wrong regex. My latest regex was: (.)=(?(\")[^\"]*|[\\S]*) I'll give yours a try. Thanks
On Thu, 06 Apr 2006 10:32:05 +0100, John Maddock wrote:
regex eParam("(.)=(\"?.*\"?)", regex::normal | regbase::icase);
The .* is greedy so it gobbles up all remaining input including spaces and quotes.
How about:
(.)=((?:\"[^\"]*\")|(?:[^[:space:]]*))
John.
it works wonderfully Thanks
participants (2)
-
Jean-Sebastien Vachon
-
John Maddock