title: Extract 2nd to last word in string
body: <p>I know how to do it in Python, but can't get it to work in R</p>
  
  <pre><code>&gt; string  &lt;- "this is a sentence"
  &gt; pattern &lt;- "\b([\w]+)[\s]+([\w]+)[\W]*?$"
  Error: '\w' is an unrecognized escape in character string starting "\b([\w"
  &gt; match   &lt;- regexec(pattern, string)
  &gt; words   &lt;- regmatches(string, match)
  &gt; words
  [[1]]
  character(0)
  </code></pre>