Re: remove all except pattern

2011-06-21 Thread Tim Chase
On 06/20/2011 12:22 PM, rameo wrote: myem...@mydomain.com hello myotherem...@mydomain.com hello mylatestem...@mydomain.co.uk Putting that in your command gives an empty output (it removes the emails). Ah...with that context, I might try to approach the problem differently. If you don't

Re: remove all except pattern

2011-06-20 Thread Tim Chase
On 06/20/2011 07:19 AM, rameo wrote: On Jun 20, 1:50 am, Tim Chasev...@tim.thechases.com wrote: hello this is an example, hello to everybody example hello I do a search for hello My output has to be: hellohello hello or hello hello hello My first thought would be something

Re: remove all except pattern

2011-06-20 Thread rameo
Hi TIm, this is the output of the text when I use your command %s/\w\+/ \=submatch(0)=~'hello'?submatch(0):'' : hello this is an example, hello to everybody hello this is the output of the text when I use your command %s/\w\+\W*/ \=submatch(0)=~'hello'?submatch(0):'' : hello this is an

Re: remove all except pattern

2011-06-20 Thread Tim Chase
On 06/20/2011 10:00 AM, rameo wrote: hello this is an example, hello to everybody hello this is the output of the text when I use your command %s/\w\+\W*/ \=submatch(0)=~'hello'?submatch(0):'' : hello this is an example, hello to everybody hello Ah...it looks like it was missing the g

Re: remove all except pattern

2011-06-20 Thread rameo
Thank you, yes now it works with hello. It doesn't work p.e. with emails. This is my command to search emails: \([A-Z0-9+_.-]\+@\([A-Z0-9-]\+\.\)\+[A-Z]\{2,6}\) p.e. myem...@mydomain.com hello myotherem...@mydomain.com hello mylatestem...@mydomain.co.uk Putting that in your command gives an

Re: remove all except pattern

2011-06-20 Thread Tim Chase
On 06/20/2011 11:35 AM, rameo wrote: This is my command to search emails: \([A-Z0-9+_.-]\+@\([A-Z0-9-]\+\.\)\+[A-Z]\{2,6}\) p.e. myem...@mydomain.com hello myotherem...@mydomain.com hello mylatestem...@mydomain.co.uk Putting that in your command gives an empty output (it removes the emails).

Re: remove all except pattern

2011-06-20 Thread rameo
Hi, Thank you for replying. I use this command to put all matches on a new line: :let @a=CR:%s//\=setreg('A', submatch(0), 'l')/gCR:%d _CR:put aCR:0d _CR I can't find out how to keep them on the same line. I tried this command: %s/\(^\|\(hello\)\@=\).\{-}\($\|hello\)\@=//g It works with text

remove all except pattern

2011-06-19 Thread rameo
Hi, I would like to know how to remove everything except pattern. p.e. hello this is an example, hello to everybody example hello I do a search for hello My output has to be: hellohello hello or hello hello hello using :%s//\=setreg('A', submatch(0), 'l')/g puts every hello on a new

Re: remove all except pattern

2011-06-19 Thread Tim Chase
On 06/19/2011 11:15 AM, rameo wrote: I would like to know how to remove everything except pattern. p.e. hello this is an example, hello to everybody example hello I do a search for hello My output has to be: hellohello hello or hello hello hello My first thought would be something