On Thursday, April 18, 2013 8:27:36 AM UTC-5, David Fishburn wrote:
> Vim 7.3.758
> 
> 
> I have the following string:
> 
> 'match /\%(if\|elsif\|unless\|given\|when\|default\)\>/ match /\<\>/  
> nextgroup=perlElseIfError skip0 skip1 skip2'
> 
> 
> 
> I was hoping (using 1 or 2 substitution commands) to find all words less than 
> or equal to 5 characters in length and remove them.
> 
> 
> But, these words have to be within "match /.../" tags.
> 
> 
> 
> So, when completed, the string above should read:
> 
> 'match /\%(\|\|unless\|\|\|default\)\>/ match /\<\>/  
> nextgroup=perlElseIfError skip0 skip1 skip2'
> 
> 
> 
> Notice the skip0, skip1, skip2 are not touched since they are not within the 
> beginning "match /" and the ending "/" of the match.
> 
> 
> My best try was the following:
> 
> >echo substitute( 'match /\%(if\|elsif\|unless\|given\|when\|default\)\>/ 
> >match /\<\>/  nextgroup=perlElseIfError skip0 skip1 skip2', '\<match 
> >/.\{-}\zs\<\w\{1,5}\>\ze.\{-}/ ', '', 'g' )
> 
> 
> 
> But it only gets rid of the "if" at the start, and doesn't work on any of the 
> other matches.
> 
> 
> TIA,
> David

I got it working *better* using \@<= instead of \zs:

\%(\<match /.\{-}\)\@<=\<\w\{1,5}\>\ze.\{-}/

But this also removes the second "match" in the line, so you'll need to refine 
it some more, using [^/] instead of . to avoid that the ending '/' is allowed 
to match the beginning pattern:

\%(\<match /[^/]\{-}\)\@<=\<\w\{1,5}\>\ze.\{-}/

Now I think it works as you intended.

-- 
-- 
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 because you are subscribed to the Google Groups 
"vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to