title: Extract number after a certain word
body: <p>I am trying to build a regex expression to extract a 6 digit number (positive or negative) after a certain string, namely 'LogL='. </p>
  
  <p>It comes from text output from certain software.</p>
  
  <pre><code>   7 LogL=-3695.47     S2=  9.0808       1891 df    2.263     0.2565    
     9 LogL= 2456.30     S2=  1.2789       1785 df    1.244     0.1354    
  </code></pre>
  
  <p>I tried the following in R:</p>
  
  <pre><code>txt &lt;- "   9 LogL= 2456.30     S2=  1.2789       1785 df    1.244     0.1354   "
  as.numeric(unlist(strsplit(sub(".*LogL=*", "", txt), " "))[1])
  </code></pre>
  
  <p>Doesn't work for positive numbers. And I imagine its very crude/ugly way of going about it.
  I tried meddling on <a href="https://regex101.com/r/wZ6gE1/2" rel="nofollow noreferrer">regex101.com</a></p>
  
  <p>Stackoverflow related questions tried: <a href="https://stackoverflow.com/questions/35947123/r-stringr-extract-number-after-specific-string">(1)</a> <a href="https://stackoverflow.com/questions/17215789/extract-a-substring-in-r-according-to-a-pattern">(2)</a> <a href="https://stackoverflow.com/questions/15451251/extract-numeric-part-of-strings-of-mixed-numbers-and-characters-in-r">(3)</a></p>
  
  <p>I am kind of lost and can't seem to understand regex expressions. I am sure this is a piece of cake. Help?</p>