ユニークなプレフィックスとサフィックスで単語を置き換える方法は?

ユニークなプレフィックスとサフィックスで単語を置き換える方法は?

testfileによって。 。スタート:

  abc: aprefixAnYthingasuffix

このsed操作は機能しません。

sed -i 's/aprefix*asuffix/mynewword/g' testfile

testfileによって。 。終わり:

  abc: mynewword

http://regexone.com/lesson/line_beginning_end

ベストアンサー1

努力する: sed -i 's/aprefix.*asuffix/mynewword/g' testfile.*「0個以上の文字」を意味し、x*「0個以上x」を意味しますaprefixxxxxxxxxxxxxxxasuffix。たとえば、一致します。

具体的には、.正規表現のワイルドカードは「任意の文字」であり、*「最後の文字のうち0個以上」はregex-ese、「最後の文字の0個以上」は.*regex-eseです。性格」。

おすすめ記事