1
import re
data = "sda 8:0 0 107374182400 0 disk \r\n\[email protected]:~[[email protected] ~]# s"
re.sub(r"[email protected]:~\[[email protected] ~\]# s","",data)
'sda 8:0 0 107374182400 0 disk \r\n\[email protected]:~[[email protected] ~]# s'
它不會被替換。我怎麼能匹配正則表達式的子字符串,並將其替換?我如何匹配一個精確的字符串和特殊字符?
注意:'awx1!= qa-dc1' – wim