a question related to substitution using regular expression

2006-07-25 Thread Xiaoshen Li
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.da

Re: a question related to substitution using regular expression

2006-07-25 Thread Charles E Campbell Jr
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:

Re: a question related to substitution using regular expression

2006-07-25 Thread Tim Chase
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 kn

Re: a question related to substitution using regular expression

2006-07-25 Thread Marshall Abrams
Why not just s/ .*// ? (For either vim or sed.) Marshall On Jul 25, 2006, at 1:09 PM, Tim Chase wrote: 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 express

Re: a question related to substitution using regular expression

2006-07-25 Thread Tim Chase
Why not just s/ .*// Good idea. It should also do the trick. There are semi-pathological edge cases where the filename contains a space, for which this might trip it up. Okay, with the other solutions I proposed, there are sick and perverted edgecases where the filename has not only a sp