-3

I have a file plenty of text strings like

text {\LXXX} more text

where XXX can be any character and its lenght is not necessary of 3 characters. I need to replace all {\LXXX} by {\LXXX}}, i.e., add } to the end of {\LXXX}. The original text must be read then

text {\LXXX}} more text

I'm trying to do that with sed, but I'm completely lost about how to create the regexp for find and replace. Can anyone help me, please?

5
  • 2
    Show us what you have searched then tried Commented 3 hours ago
  • 1
    Can X be a }? Commented 3 hours ago
  • @choroba No, X can be only letters from the latin alphabet or numbers Commented 3 hours ago
  • "but I'm completely lost about how to create the regexp for find and replace" - you capture the {\LXXX} parts, and then simply replace with capture + }? For the capturing, something like ({\\L[^}]+}) should do. Commented 2 hours ago
  • Perhaps sed -E 's/(\{\\L[[:alnum:]]*\})/\1}/g' if XXX is allowed to be zero characters long or sed -E 's/(\{\\L[[:alnum:]]+\})/\1}/g' if it has to be at least one character long. Please make your requirements chrystal clear and show us what you've tried. Commented 2 hours ago

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.