title: Regex to find last word in a string (Python)
body: <p>I am trying to write a simple regex that finds if the last word in the string is a specific one.</p>
  
  <p>I wrote something like this <code>"(\W|^)dog$"</code>. (Check if last word in the sentence is dog) </p>
  
  <p>This regex is correct but in python it is returning nothing when i type something like <code>"I like dog"</code>. </p>
  
  <p>I tested this in the Rubular regex editor and it seems to work.</p>
  
  <p>Am I doing something wrong ? </p>
  
  <p>EDIT : Adding my simple code</p>
  
  <pre><code>import re
  pm = re.compile("(\W|^)dog$")
  has = pm.match("i love dog")
  print(has)
  </code></pre>