I have a request to replace the pattern A.*D
with E.*E
. however my string have multiple combinations to meet this pattern, like bAcDAccDAccccD
. if I just use the normal way to replace, I can't get my expected result, i.e., bEcEEccEEccccE
:
echo 'bAcDAccDAccccD'|sed 's/A\(.*\)D/E\1E/g'
--> bEcDAccDAccccE
.
How to solve such problem?