with vim script,
Let me say that I want to find word "This" from the following expression
match("testingThis", '\ving(.*)')
I tried with some different options, getmatches()
, substitute()
, not luck yet :(
Is there a way get matches in vim like in ruby or php, i.e. matches[1]
--------------------------EDIT----------------------------
from h function-list
, as glts
mentioned, I found matchlist()
unlike matchstr()
, which always returns full matches, like matches[0], it returns full array of matches.
echo matchstr("foo bar foo", '\vfoo (.*) foo') " return foo bar foo
echo matchlist("foo bar foo", '\vfoo (.*) foo') " returns ['foo bar foo', 'bar', '', '', '', '', '', '', '', '']