
Hi all,
I have a question regarding boost::regex.
I have one regex which should identify my string AND cut it into pieces.
I've tried with regex_token_iterator and cmatch and failed.
code:
#include <string>
#include <iostream>
#include

I have a question regarding boost::regex.
I have one regex which should identify my string AND cut it into pieces. I've tried with regex_token_iterator and cmatch and failed.
How about (caution, untested, off the top of my head!):
#include <string>
#include <iostream>
#include

How about (caution, untested, off the top of my head!):
#include <string> #include <iostream> #include
int main() { std::string s("s0,s1,s2"); boost::regex re("\\s*(s[0-9])\\s*(?:,\\s*)?");
// 1. attempt boost::sregex_token_iterator i(s.begin(), s.end(), re, 1), j; while(i!=j) { std::cout << *i++ << std::endl; } }
HTH, John.
Thanks, that solved my problem.
participants (2)
-
Dejan
-
John Maddock