title: Find first number anywhere after a specific pattern in R
body: <p>I am trying to identify a number that occurs after a certain substring in R.</p>
  
  <p>For example:</p>
  
  <pre><code>sa &lt;- "100 dollars 200"
  </code></pre>
  
  <p>In the above string, to find the number that appears after the word <code>dollar</code>, I execute the below code:</p>
  
  <pre><code>str_match_all(sa,"(?&lt;=dollars )\\d+") 
  </code></pre>
  
  <p>and I get the below outcome:</p>
  
  <pre><code>  [[1]]
       [,1] 
  [1,] "200"
  </code></pre>
  
  <p>However, when I use the following input:</p>
  
  <pre><code>sa &lt;- "100 dollars for 200 pesos"
  </code></pre>
  
  <p>I fail terribly to get the output as <code>200</code>.</p>