Reputation: 21
I have the following lines in a file :
|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|
I want to change the above lines to
|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|
I tried :%s/abcd*.xyz/q/g
but that does not seem to work. Please can anyone suggest how to go about this.
Upvotes: 1
Views: 1488
Reputation: 378
You must use:
:%s/abcd.*\.xyz/q/g
For match .
you need to write as\.
, remember a simple dot .
is also a command.
Upvotes: 0
Reputation: 2946
If we can count on having the spaces and the |
then you can use:
:%s/\|(.*)\| (abcd_.*) \|(.*)\|/\1q\3
PS: you can use https://regex101.com/r/DHLbIx/1 to help you with the matching
Upvotes: 0