Regex - Trim character at the end of a string
        Posted  
        
            by Torez
        on Stack Overflow
        
        See other posts from Stack Overflow
        
            or by Torez
        
        
        
        Published on 2010-05-29T16:14:20Z
        Indexed on 
            2010/05/29
            16:22 UTC
        
        
        Read the original article
        Hit count: 257
        
I am trying to remove a trailing - (dash) at the end of the string. Here is my code:
<?php
$str = 'SAVE $45! - Wed. Beach Co-ed 6s (Jul-Aug)';
echo ereg_replace('([^a-z0-9]+)','-',strtolower($str));
?>
produces this:
save-45-wed-beach-co-ed-6s-jul-aug-
How can I remove a specific trailing character only if its there, in this case the dash?
Thanks in advance.
© Stack Overflow or respective owner