Friday, March 26, 2010

Re: get matched sting after search()

On 2010-03-26, Yakov wrote:
> How do I get the matching string search()
> (what is $& in perl), or submatches (what is $1,$2 in perl) ?

My first thought was to reply with

:help sub-replace-special
:help submatch()

but that won't help you if you are searching with search(). In that
case, Vim appears to offer only a two-step solution:

1. use search() to find the line matching the pattern; then
2. use matchlist() to find the submatches within that line,
using the same pattern.

See

:help matchlist()

Regards,
Gary


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

To unsubscribe from this group, send email to vim_use+unsubscribegooglegroups.com or reply to this email with the words "REMOVE ME" as the subject.

No comments: