boukli
July 6th, 2012, 08:42 PM
Hi all,
I'm trying to a edit a big file, in which there are, on each line, more than one occurrence of "pattern1" and "pattern2", as follows :
bababa pattern1 bibibi pattern2 bobobo pattern1 bebebe pattern2 bububu etc.
I used Vim with the following command :
:%s/pattern1.*pattern2//
The effect of it is that it takes the first occurrence of pattern1, and delete all that follows until the last occurrence of pattern2 is reached. But what I want is to delete the text between each "pattern1-pattern2", so that the example above becomes :
bababa bobobo bububu
How can I do this ?
I'm trying to a edit a big file, in which there are, on each line, more than one occurrence of "pattern1" and "pattern2", as follows :
bababa pattern1 bibibi pattern2 bobobo pattern1 bebebe pattern2 bububu etc.
I used Vim with the following command :
:%s/pattern1.*pattern2//
The effect of it is that it takes the first occurrence of pattern1, and delete all that follows until the last occurrence of pattern2 is reached. But what I want is to delete the text between each "pattern1-pattern2", so that the example above becomes :
bababa bobobo bububu
How can I do this ?