Preamble
Maybe you want to convert this:
aaaa
To:
1aaa1
So let's propose this:
echo aaaa | sed --regexp-extended 's/(.*)a/1\11/'
→
1aaa1
Question
Is 1\11
a 100% valid unambiguous sed
pattern? Am I complying with all sed
good practice with such replacement?
I mean that 1\11
maybe could be both of these:
- replace with char
1
, then the 1° matched group, then another char1
(→ current behavior) - replace with char
1
, then the 11° matched group (→ causing an exception)
At the moment it seems my sed version has the first interpretation. Anyway I don't know if this is documented or if it can be wrote in a better way in sed
.
Thank you for any clarification. In the meanwhile I will not build a castle on this.
At the moment I'm using GNU sed 4.7.