What's a regex pattern to trim the hyphens from the start and end of a string?
-----name1-name2-----
should become
name1-name2
^(-+).+(-+)$
doesn't seem to work...
What's a regex pattern to trim the hyphens from the start and end of a string?
-----name1-name2-----
should become
name1-name2
^(-+).+(-+)$
doesn't seem to work...
I would take the opposite approach, and pull the middle out like this:
^-+(.+?)-+$
You need to match either the beginning or the end like this:
(^-+)|(-+$)
If I try this out in PowerShell I get the following result:
PS> "-----name1-name2----" -replace "(^-+)|(-+$)", ""
name1-name2