Friday, April 20, 2012

Re: matchend() and \zs

On Friday, April 20, 2012 2:45:28 AM UTC-5, rameo wrote:
>
> 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.

submatch() only works inside a substitute() call or inside a :substitute command (:help sub-replace-expression). It says this explicitly in :help submatch(). In the future, please read the help topics on the functions you are using before posting to the list.

In order to use the matched text, you can try matchstr() or matchlist() instead. Again, had you read the help for match(), you would have been directed to these functions.

--
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

No comments: