IDK where you found that example — it is not standard C++ and is not supported by std::string.
Are you looking for a function that finds a substring that:
• begins in a specific subrange, but may end outside that range, or
• both begins and ends in a specific subrange
?
you may have to use substr() with it.
I don't see a working way to specify end pos
1 2 3 4 5 6 7 8 9 10 11
int main ()
{
std::string str ("There are two needles in this haystack with needles.");
auto sub = str.substr(0,5);
cout << sub << endl;
cout << sub.find("two",3) << endl;
sub = str.substr(5,20);
cout << sub.find("two",3)+5 << endl; //don't forget to add the startpos back to the loc in the substring
}