title: Regex - Trim character at the end of a string
body: <p>I am trying to remove a trailing <code>-</code> (dash) at the end of the string. Here is my code:</p>
  
  <pre>
  &lt;?php
  
  $str = 'SAVE $45! - Wed. Beach Co-ed 6s (Jul-Aug)';
  
  echo ereg_replace('([^a-z0-9]+)','-',strtolower($str));
  
  ?&gt;
  </pre>
  
  <p>produces this:</p>
  
  <pre>
  save-45-wed-beach-co-ed-6s-jul-aug-
  </pre>
  
  <p>How can I remove a specific trailing character only if its there, in this case the dash?</p>
  
  <p>Thanks in advance.</p>