title: How to search in a string within a given range?
body: <p>I have to search a String for a specific character, within a specified range. The code I made is as follows:</p>
  
  <pre><code>str.erase(str.begin(), str.begin()+5);
  str.erase(str.begin() + 9, str.end()); // The range to be searched has been specified ie 5th index to 9th index
   if(  str.find('a') != string::npos){
         cout &lt;&lt; "YES, it exists" &lt;&lt; endl;
     }else{
         cout &lt;&lt; "No, it doesnt" &lt;&lt; endl;
     }
  </code></pre>
  
  <p>The above code works as expected, but I would love to know if there is a standard library function that would do this work.(Probably in one line)</p>