Friday, March 26, 2010

Re: get matched sting after search()

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

search() doesn't give that to you. You will either (without the n flag)
have to examine the line the cursor lands on, or use the p flag to see
whether a sub-pattern was matched.

See :help search()


If you can't do without perl regexp results, well,

if has('perl')
function s:WhateverTheName()
perl << EOF
...perl script here...
EOF
" EOF (above) MUST be in column 1 !!!
endfunction
call s:WhateverTheName()
else
echoerr 'Not compiled with +perl'
endif

see :help script-here

but then, of course, you'll be limited to Vim executables with perl
support compiled-in (and, if dynamic, a perl library that can be found
at runtime).


Best regards,
Tony.
--
A.I. hackers do it with robots.

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

Post a Comment