Well my first issue would be that you have posted what you started with and what solution you tried to use, but at no point do you show what your desired output should be?
I also have issues with the question as well as your proposed solution:
1. The question :- replace all instances of _-, -_, -- with - (dash) ... my issue here is, should the solution be recursive, ie based on the first 3 characters of your example '--_', now if recursive
the solution would first replace the first 2 dashes with a single dash and then on the next pass it will change the now single dash and an underscore to be a single dash, hence these 3 characters
would become simply ... '-' ... is this correct?
2. Proposed solution :- [_-|-_|--] ... this part of your regex says, look for a dash, a pipe or an underscore ... the fact that you have used patterns is irrelevant as the square brackets have indicated
you will show a group of individual characters or a group, such a-z, where any one of those characters can be replaced by your dash. You may have meant something more akin to:
Code:
sed -r 's/--|-_|_-/-/g'
Again this solution will not provide the recursive option spoken of above.
So as said initially, if you show us the desired output it can greatly help us to help you in coming up with a solution.