Hi.
I'm working on a method that should search a string of text and extract text in-between tags, and store the resulting strings in a vector<string> to be returned.
Example:
string to search: "dummy<t>test</t><t>test2</t>dummy"
tags: "<t>", "</t>"
desired result strings in vector: "test", "test2"
I'm using the regular expression library by including <regex.h>.
If i build a pattern like: "<t>" + "(.*)?" + "</t>"
Then the result is the classic greedy-problem where it stops at the very last tag instead of the ones in between.
But according to the man page and a regcomp() error message, I cannot use "(.*?)" to create a lazy / non-greedy expression.
Is there another way to do this?
Best reg.
Chris
I'm working on a method that should search a string of text and extract text in-between tags, and store the resulting strings in a vector<string> to be returned.
Example:
string to search: "dummy<t>test</t><t>test2</t>dummy"
tags: "<t>", "</t>"
desired result strings in vector: "test", "test2"
I'm using the regular expression library by including <regex.h>.
If i build a pattern like: "<t>" + "(.*)?" + "</t>"
Then the result is the classic greedy-problem where it stops at the very last tag instead of the ones in between.
But according to the man page and a regcomp() error message, I cannot use "(.*?)" to create a lazy / non-greedy expression.
Is there another way to do this?
Best reg.
Chris