[英]Replace string with special characters using perl
我正在嘗試替換一個字符串
</string§>
同
new string line 1
new string line 2
在Linux上使用perl。
問題是,它將不接受<和>以及/。
這就是我得到的:
perl -i -pe 's/\<\/string§\>/new string line 1 \n new string line 2/se' file.xml
有人可以幫忙嗎?
謝謝!
您不需要s
和e
修飾符,還可以使用其他正則表達式除法器( /
除外)來避免轉義:
perl -pe 's~</string§>~new string line 1 \nnew string line 2~' file.xml
new string line 1
new string line 2
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.