How to remove all words between two special chars using sed? Note that the original line has to be in the result aswell.
Current code:
echo 'a "removeme" b +removeme+ c *removeme#d+removeme~ .123' | sed -r '/\W/ p; s/\W[^\W]*\W//g'
Result:
a "removeme" b +removeme+ c *removeme#d+removeme~ .123
a123
Expected result:
a "removeme" b +removeme+ c *removeme#d+removeme~ .123
a b c d .123
#d+
will be also removed due to the rule words between special chars - it won't be in the result