title: Find only first std::regex match efficiently
body: <p>I'm trying to find an efficient way to greedily find the first match for a <code>std::regex</code> without analyzing the whole input.</p>
  
  <p>My specific problem is that I wrote a hand made lexer and I'm trying to provide rules to parse common literal values (eg. a numeric value).</p>
  
  <p>So suppose a simple let's say</p>
  
  <pre><code>std::regex integralRegex = std::regex("([+-]?[1-9]*[0-9]+)");
  </code></pre>
  
  <p>Is there a way to find the longest match starting from the beginning of input without scanning all of it? It looks like <code>std::regex_match</code> tries to match the whole input while <code>std::regex_search</code> forcefully finds all matches.</p>
  
  <p>Maybe I'm missing a trivial overload for my purpose but I can't find an efficient solution to the problem.</p>
  
  <p>Just to clarify the question: I'm not interested in stopping after first sub-match and ignore the remainder of input but for an input like <code>"51+12*3"</code> I'd like something that finds first <code>51</code> match and then stops, ignoring whatever is after.</p>