Saturday, May 29, 2010

Re: Regex matching the first occurrence of a string

On 05/28/2010 09:50 PM, ShayAllen wrote:
>
> I want to match everything between and including Begin and End. There are
> several blocks in the file:
>
> Begin
> ssss
> dfsdfsdf
> sdfsdf
> End
>
> Begin
> sasdfsa
> sdfgsd
> hghfgh
> End
>
> My best guess so far:
> :%s/Begin\_.*\(End\)\{-1}/This was one block/
> Doesn't work

Without details of what "Doesn't work" means, it's a little hard
to guess. Can your blocks be nested?

Begin
stuff
Begin
stuff2
stuff3
End
stuff4
End

Does case matter? Can you have begin/end text in other stuff?

Begin
stuff
this is not the End
more stuff
End

-tim


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