title: Extracting Words in Sentence with Regex
body: <p>I want to extract last two words of a sentence and replacing with other words. Let me describe by an example:</p>
  
  <pre><code>word1 word2 word3 word4 .... wordn-2 wordn-1 wordn
  </code></pre>
  
  <p>What I want is to replace this sentence with regex so I get sentence like this:</p>
  
  <pre><code>wordn-1 wordn : word1 word2 word3 word4 .... wordn-2
  </code></pre>
  
  <p>I tried</p>
  
  <pre><code>^(\w)* (\w)$
  </code></pre>
  
  <p>regex code to replace with</p>
  
  <pre><code>$2 : $1
  </code></pre>
  
  <p>but it is not working. Thanks in advance for suggestions.</p>