Monday, November 22, 2010

Re: Regular Expression question

On 11/22/2010 02:39 PM, Jeff Lanzarotta wrote:
> For example, I have some lines:
>
> 1. word1 sometext
> 2. word1 sometext word2 sometext
> 3. word1 sometext
> 4. word1 sometext
> 5. word1 sometext word2 sometext
> 6. word1 sometext word2 sometext
>
> All I want is lines 1, 3, and 4.
>
> word1 sometext
> word1 sometext
> word1 sometext

Dr. Chip's "LogiPat.vim" script [1] makes this pretty easy:

:LogiPat "word1" & !"word2"

which produces this regexp:

\%(.*word1.*\&^\%(\%(word2\)\@!.\)*$\)

Hope this helps,

-tim


[1]
http://www.vim.org/scripts/script.php?script_id=1290


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