Sed non greedy curly braces match
Posted
by Cesar
on Stack Overflow
See other posts from Stack Overflow
or by Cesar
Published on 2010-06-01T20:05:41Z
Indexed on
2010/06/01
22:33 UTC
Read the original article
Hit count: 210
I have a string in a file a.txt
{moslate}alho{/moslate}otra{moslate}a{/moslate}
a need to get the string otra
using sed.
With this regex
sed 's|{moslate}.*{/moslate}||g' a.txt
a get no output at all but when i add a ?
to the regex
s|{moslate}.*?{/moslate}||g a.txt
(I've read somewhere that it makes the regex non-greedy) i get no match at all, i mean a get the following output
{moslate}alho{/moslate}otra{moslate}a{/moslate}
How can i get the required output using sed?
© Stack Overflow or respective owner