// useful function
bool extractManyString(const string& contents, const string& beforeString, const string& afterString, StringVector& matchedStrings)
{
bool cont = true;
// start the search at position 0
int i=0;
// continue searching while we are finding strings
while (cont)
{
// find the next two matches
int start = int(contents.find(beforeString, i));
if (start != int(string::npos) && start + int(beforeString.length()) + int(afterString.length()) + 1 < int(contents.length()) )
{
int end = int(contents.find(afterString, start+1));
// if we found a match
if (end != int(string::npos))
{
// cut it out
string el = contents.substr(start + int(beforeString.length()), end - start - int(beforeString.length()));
// add it to the vector
matchedStrings.push_back(el);
// increase the starting index
i = end + 1;
}
else
{
// we didn't find it, stop searching
cont = false;
}
}
else
{
cont = false;
}
}
// return true if we found one or more matches
return (matchedStrings.size() > 0);
}