title: Regex pattern match search over an un-ordered map in cpp
body: <p>I have an unordered_map, its key and values are string type.</p>
  
  <p>key is a regex.</p>
  
  <p>Number of elements in the map is about 2,50,000.</p>
  
  <p>I have to find the element whose key(regex) returns exactly one match against the string received in request.</p>
  
  <p>When I iterate over the map by each element, in worst case it takes around to 10 seconds.</p>
  
  <p>My sample code:</p>
  
  <pre><code>string string_to_match = "Find my Regex";
  for (MyMap::const_iterator it = myMap.begin();
          it != myMap.end(); ++it) {
      //cout &lt;&lt; it-&gt;first &lt;&lt; "\n";
      if (regex_match( string_to_match ,
              regex(it-&gt;first,std::regex::ECMAScript | std::regex::icase))) {
          cout &lt;&lt; ", " &lt;&lt; it-&gt;second &lt;&lt; "\n ";
          break;
      }
      ++it;
  }
  </code></pre>
  
  <p>is there any way I could reduce the time taken...</p>