I am looking for a way to convert one word to another while "capturing" the case of the match that is substituted. An example:
I have the text:
Begin the beginning
Now I want to convert this to
End the ending
To do so I need a command like the one below:
s/([Bb]egin/ [CASE OF CAPTURE][Ee]nd/g
But then with a correctly working [CASE OF CAPTURE][Ee]
part.
How do we get the case of the capture (being upper or lowercase begin) and substitute with same (upper or lowercase end)?