title: C++ how to get ONLY integers from complex string
body: <p>I have few strings, each one contains one word and several integer numbers (One string is whole line): </p>
  
  <pre><code>Adam 2 5 1 5 3 4
  John 1 4 2 5 22 7
  Kate 7 3 4 2 1 15
  Bill 2222 2 22 11 111
  </code></pre>
  
  <p>As you can see, each word/number is separated with space. Now, I want to load these data into a map, where word (name) would be the key and the value would be vector of the numbers in line. I already have key values in separated temporary stl container, so the task is to load only the integer numbers from each line to 2D vector and then merge these two into map. 
  The question is, is there any C++ function, which would avoid words and white spaces and get only integers from a string, or I have to search strings char-by-char like 
  <a href="https://stackoverflow.com/questions/21895399/read-only-integers-from-complex-string-in-c/21895512#21895512">here</a> ?</p>
  
  <p>I found only partial solution, which is not able to get more than one digit number:</p>
  
  <pre><code>vector&lt;int&gt; out;
  
  for (int i = 0; i &lt; line.length(); i++) {
  
      if (isdigit(line.at(i))) {  
          stringstream const_char;
          int intValue;
          const_char &lt;&lt; line.at(i); 
          const_char &gt;&gt; intValue;
          out.push_back(intValue);
      }
  }
  </code></pre>