title: need help with postgresql regexp_replace
body: <p>I need to get rid of trailing repeating non_alphanumeric symbols like</p>
  
  <p><code>"thanks ! !!!!!!!"</code> to <code>"thanks !"</code></p>
  
  <p>If these different symbols then they are ignored.</p>
  
  <p>I quite new to regex,
  so I came up with </p>
  
  <pre><code>regexp_replace('Thanks . . . .  ', '((\\W)\\s*)(\\2\\s*)+', '\\2')
  </code></pre>
  
  <p>to try it out.</p>
  
  <p>However i realise the trailing space after 'thanks' causes some problem. I would get back <code>"thanks "</code> instead of <code>"thanks ."</code> This is kinda strange because I used an online regex tool and the first whitespace was not matched. Can anyone help?</p>
  
  <p>note: I did insert the double backslash.</p>