On Thursday, April 19, 2012 8:12:55 PM UTC+2, Ben Fritz wrote: > On Thursday, April 19, 2012 5:35:11 AM UTC-5, 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? > > > > If I remove "sep" before '\zs' it works. > > (echo matchend(getline(1), '\zs\d\+\ze-', 23) > > gives 26 as output. > > > > Does matchend not work with \zs? > > How can I resolve this problem? > > I haven't looked in detail at your problem, but I wonder if you're running > into the same issue as this recent thread: > > https://groups.google.com/d/topic/vim_use/prE5uPDeETU/discussion > > In summary, giving a starting position to matchend() without giving a count > treats the string as if the beginning of the string is at the starting > position. So anything before the starting position cannot be used in the > match, unless you provide a count as well.
Hi Ben, Yes that's me. Thanks for the answer. What do you mean with provide a count? How do you provide a count to match() ------ After all these match() and matchend() problems, I'm trying to view if matches can be captured by using the submatch(0) and adding them to a register. Isn't this a bit dangerous because you have to return the submatch (in order to left the buffertext unchanged)? However I tested that it captures all matches whatever the regex is. -- 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
