I wouldn’t trust a regex in poorly-formatted input, I think it’d be more resilient finding the delimiters like Broco said and then checking them (even number found, alternating <
and >
) then extracting the words with ranges.
If you’re sure the string is always well-formed, put it in an istringstream
and read it out a word at a time.