title: regex: get text between two words (in R)
body: <p>I have a text document and I'm trying to get the text between the words "abstract" and "keywords" (in R). This is the code I'm using:</p>
  
  <pre><code>gsub(".*abstract\\s*|keywords.*", "\\1", string)
  </code></pre>
  
  <p>However, this didn't work because somewhere else in the text the word "abstract" occurred so I made it non-greedy like this (added ? in front of abstract)</p>
  
  <pre><code>gsub(".*?abstract\\s*|keywords.*", "\\1", string)
  </code></pre>
  
  <p>But for some reason it now takes the text between "abstract" and "keywords" (which is what I want), but ALSO the text starting from the second "abstract" appearing in the text, all the way to the end.
  Any ideas?</p>