Tuesday, October 2, 2012

Re: Problem with a regular expression in Vim

Xell Liu <xell.liu@gmail.com> a écrit:
>
> Thanks very much for your detailed explanation.
>
> In fact, by pseudocode I think I can put my requirement like this:
>
> 1. Search for the first pair of "==" from the beginning location where
> the search starts.
> 2. Extract the contents in the pair of "==" as the first match result.
> 3. Disable/Invalidate/Remove the matched contents with its "==" surroundings.
> 4. Repeat from 1. until reaching the end of the search range.
>
> So, is it possible to do that by regular expression? I'm not very
> familiar with the concepts of greedy/non-greedy or zero-match (like
> the queer things of \@! or \@<= etc.) or . Will they help?

I don't know what you mean exactly by "extract" in point 2, but to me it
sounds like a simple capture (or sub-expression):

==\([^=]\+\)==

That way, the "=" signs are part of the match, but you can work on the
enclosed material only (with \1).

Best,
Paul

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

Post a Comment