Searching std::string between a limit

c++, stl, string

Solution

If you really want to limit the length of the sequence that gets traversed (presumably because the string is very long compared to the interesting region), use `std::search` and pass it the corresponding iterators into the string.

Problem

if you know the start and end positions in string from where to begin and end the search. For example - ``` string s = StringStringString |S |t |r |i |n |g |S |t |r |i |n |g |S |t |r |i |n |g 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 ``` How would you find "tr" in the string specifying the the position to begin search is at index 6 and the position to end the search is index 9. I'm trying a set a limit of search so it wouldn't go beyond it.

Original source