I'm having a string like
"<firstname>Anna</firstname>"
or
"<firstname>Anna Lena</firstname>"
and I want to use Regex to get the name out of it (so only "Anna" or "Anna Lena"). Currently I'm using:
std::regex reg1 ("(<firstname>)([a-zA-Z0-9]*)(</firstname>)");
and
std::regex_replace (std::back_inserter(result), input.begin(), input.end(), reg1, "$2");
which works well with only one name, but apparently it misses anything after that because it doesn't consider whitespaces. Now I've tried adding \s
like ((([a-zA-Z0-9]*)|\s)*)
but my IDE (Qt) tells me, that that \s
is an unknown escape sequence.
Right now, "<firstname>Anna Lena</firstname>"
results in "<firstname>Anna"
.
How do I solve this in an elegant way?