Xiaoshen Li wrote:
Dear All,
My file is like the following:
data_1.dat pre= -1908.77 post= -48977.33 diff= -448.947
data_2.dat pre= -444.333 post= -333.545 diff= -777.333
.
.
I hope to find out a regular expression subtitution commad to delete
everything after "dat" to get a file like:
data_1.dat
data_2.dat
.
.
I know visual mode will do the work too. But I still hope to find out
the substitution command using regular expression so I can use sed to
make it automatic.
Any of these will work with vim:
:%s/\.dat\zs.*$//
:%s/\.dat/.*$/.dat/
:%s/\s\+pre.*$//
:%s/^\(data.\{-}\.dat\).*$/\1/
sed doesn't support the same regexp set that vim does.
Regards,
Chip Campbell