Regex - nested patterns - within outer pattern but exclude inner pattern

后端 未结 5 1936
野的像风
野的像风 2020-12-11 12:41

I have a file with the content below.

 ${ dontReplaceMe } ReplaceMe ${dontReplaceMeEither} 

I want to match \'Replac

5条回答
  •  粉色の甜心
    2020-12-11 12:56

    sed -i 's/\sReplaceMe\s<\/td>/Replaced<\/td>/gi' input.file
    

    worked for me.

    you may consider using -i.bak to backup the old file, in case of a mistake.

    alternatively,

    perl -pi -e 's/\sReplaceMe\s<\/td>/Replaced<\/td>/g' temp

    also works, again, note the -pi.bak to backup.

提交回复
热议问题