我在文件中包含以下几行:
|other words in line| abcd_1234.xyz |other words in line|
|other words in line| abcd_2345.xyz |other words in line|
|other words in line| abcd_3456.xyz |other words in line|
|other words in line| abcd_4567.xyz |other words in line|
我想将以上几行更改为
|other words in line| q |other words in line|
|other words in line| q |other words in line|
|other words in line| q |other words in line|
|other words in line| q |other words in line|
我尝试过:%s/abcd*.xyz/q/g
,但这似乎不起作用。请任何人建议如何解决此问题。
尝试以下操作:
:%s/(abcd_[0-9]{4}\.xyz)/q/g
如果我们可以指望有空格和|
,那么您可以使用:
:%s/\|(.*)\| (abcd_.*) \|(.*)\|/\1q\3
PS:您可以使用https://regex101.com/r/DHLbIx/1帮助您进行匹配