Sunday, May 30, 2010

Re: Regex matching the first occurrence of a string

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
>
> What am I missing?
> Thanks.
>

Fair questions, Tim. No nested blocks or other tricky stuff. Brett's
solution worked fine and was an instructive example for me. Thanks.

--
View this message in context: http://old.nabble.com/Regex-matching-the-first-occurrence-of-a-string-tp28712875p28725924.html
Sent from the Vim - General mailing list archive at Nabble.com.

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