How do I replace a pattern by looking at sentence symbol by using sed?
Input
this-
-this-
Results I want
start
middle
My code
sed 's/[a-zA-Z]-/start/g'
sed 's/-[a-zA-Z]-/middle/g'
Results I get
abastart
Am I doing something wrong?
This should do:
-r
or-E
for extended regex+
to tell its 1 or more character^
to tell to start from beginning of line;
to have more than onesed
block in one line$
to make sure whole line is matcheds/^[a-zA-Z]+-$/start/