Wednesday, October 3, 2012

Re: Problem with a regular expression in Vim

Hi Paul,

By extraction I mean that what I need to match is only the contents
without the surroundings "==" (i.e. extracting "aaa" from "==aaa==").

I certainly know that I could use \(\) to get the contents afterwards.
But I want to know how to match the contents solely. For example,
while using :match command, the surroundings outside \(\) will be
always highlighted according to your suggestion.

On Wed, Oct 3, 2012 at 2:55 PM, Paul Isambert <zappathustra@free.fr> wrote:
>> 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: