Is there an easy way to replace characters at the beginning and end of a string, but not in the middle? I need to trim off dashes. I know trim() exists, but it only trims whitespace.
Here's my use case:
Input:
university-education
-test
football-coach
wine-
Output:
university-education
test
football-coach
wine