It works perfectly :)

2012/10/30 Ben Fritz <[email protected]>

> On Tuesday, October 30, 2012 1:22:18 PM UTC-5, niva wrote:
> > Hi,
> >
> > I am using this kind of code in order to modify line content :
> >
> > let patternOfxembh='^.*one="\(\d\+\)".*two="\(\d\+\)"'
> > if line =~ patternOfxembh
> >       echo line
> > endif
> >
> > The recognition is working well and then I can echo my line but is it
> possible to do an echo of backward reference: value of \(\d\+\).
> >
> > I would like to avoid to use substitute and using again the same pattern
> on the line.
> >
>
> You cannot use the captured groups at a later time after doing a =~ or
> substitute().
>
> However, you can use the matchlist() function to give you a list of all
> the matches which you can use later. This function returns an empty list if
> there are no matches, so to avoid doing regex matching twice you could do:
>
> let lineMatches = matchlist(...)
> if !empty(lineMatches)
>   echo line
>   ...
> endif
>
> --
> 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
>

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

Reply via email to