When we match a pattern using sed, the matched pattern is stored in the \"ampersand\" (&) variable. IS there a way to replace a character in this matched pattern using the a
If I guessed right, what you want to do is to apply a subsitution in a pattern matched. You can't do that using &. You want to do this instead:
echo apple1 apple3 apple1 apple2 botemo1 | sed '/apple./ { s/apple1/apple2/g; }'
This means that you want to execute the command substitution only on the lines that matches the pattern /apple./.