我有一個文件中的字符串A.TXT桑達非貪婪的大括號匹配
{moslate}alho{/moslate}otra{moslate}a{/moslate}
需要使用sed來得到字符串otra
。
有了這個表達式
sed 's|{moslate}.*{/moslate}||g' a.txt
一個得到任何輸出,但是當我添加?
的正則表達式
s|{moslate}.*?{/moslate}||g a.txt
(我讀的地方,它使正則表達式非貪婪)我得不到任何匹配,我的意思是得到以下輸出
{moslate}alho{/moslate}otra{moslate}a{/moslate}
我怎樣才能得到所需的輸出使用sed?