On 07:04 Thu 19 Apr , rameo wrote: > On Thursday, April 19, 2012 1:09:10 PM UTC+2, jott...@googlemail.com wrote: > > Hi, > > > > rameo wrote: > > > My file - first line: > > > an 91.010 &System.-sep010- <Nop> > > > > > > I want to copy all numbers after -sep > > > echo match(getline(1), 'sep\zs\d\+\ze-') > > > gives 23 as output. > > > All ok. > > > > > > but > > > echo matchend(getline(1), 'sep\zs\d\+\ze-', 23) > > > gives -1 as output. > > > Why? > > > > because the 23 that was returned from match() is the position of the > > first digit, not the position of 'sep'. Thus you try to find > > 'sep\zs\d\+\ze-' in a string that for matchend() seems to consist only > > of > > > > 010- <Nop> > > > > > > Regards, > > J�rgen > > > > -- > > Sometimes I think the surest sign that intelligent life exists elsewhere > > in the universe is that none of it has tried to contact us. (Calvin) > > Thanks Jurgen, > > I use match() and matchend() to copy search matches to the clipboard > or remove them out of the text. > > What can I do to make match() and matchend() work in order to copy p.e. the > numbers after -sep? > > Regards, > Raimond > > -- > You received this message from the "vim_use" maillist. > Do not top-post! Type your reply below the text you are replying to. > For more information, visit http://www.vim.org/maillist.php
It seems that echo matchend(getline(1), '\d\+\ze-', 23) should work just fine, where 23 is obtained by match(getline(1), 'sep\zs\s\+\ze-') You do not need to match sep twice. Best, Marcin -- You received this message from the "vim_use" maillist. Do not top-post! Type your reply below the text you are replying to. For more information, visit http://www.vim.org/maillist.php