How to match a certain string after an empty line?

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

How to match a certain string after an empty line?

meino.cramer
Hi,

A listing of files with absoulte paths contains somthing like this

01 /home/user1/foo
02 /home/user1/bar
03 /home/user1/gnu
04 /home/user2/alice
05 /home/user1/gnats
06 /home/user2/alice
07
08 /home/user2/alice
09 /home/user1/bob
10 /home/user1/snafu
11 /home/user2/alice

(line numbers are only for reference in this
mail and not really part of the text/file!)

I want to match line 08 only. Or in other
words, I want to match
^$/home/user2/alice

Unfortunately the search pattern doesnt work
here.

How can I acchieve the correct pattern match?

Thank you very much in advance!
Best regards and have a nice sunday!
mcc




--
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
Reply | Threaded
Open this post in threaded view
|

Re: How to match a certain string after an empty line?

Taylor Hedberg
I would use this pattern:

    \n\n\zs\/home\/user\/alice

There's probably more than one way to do it though.

--
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
Reply | Threaded
Open this post in threaded view
|

Re: How to match a certain string after an empty line?

Jean-Rene David-2
In reply to this post by meino.cramer
* [hidden email] [2011.08.06 23:30]:

> 01 /home/user1/foo
> 02 /home/user1/bar
> 03 /home/user1/gnu
> 04 /home/user2/alice
> 05 /home/user1/gnats
> 06 /home/user2/alice
> 07
> 08 /home/user2/alice
> 09 /home/user1/bob
> 10 /home/user1/snafu
> 11 /home/user2/alice
>
> (line numbers are only for reference in this
> mail and not really part of the text/file!)
>
> I want to match line 08 only. Or in other
> words, I want to match
> ^$/home/user2/alice
>
> Unfortunately the search pattern doesnt work
> here.

No, because $ matches the end of the line only
when it's at the end of the pattern.

You already got one answer. Here's another:

:/^$/+1g/pattern

--
JR

--
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
Reply | Threaded
Open this post in threaded view
|

Re: How to match a certain string after an empty line?

meino.cramer
Jean-Rene David <[hidden email]> [11-08-07 06:04]:

> * [hidden email] [2011.08.06 23:30]:
> > 01 /home/user1/foo
> > 02 /home/user1/bar
> > 03 /home/user1/gnu
> > 04 /home/user2/alice
> > 05 /home/user1/gnats
> > 06 /home/user2/alice
> > 07
> > 08 /home/user2/alice
> > 09 /home/user1/bob
> > 10 /home/user1/snafu
> > 11 /home/user2/alice
> >
> > (line numbers are only for reference in this
> > mail and not really part of the text/file!)
> >
> > I want to match line 08 only. Or in other
> > words, I want to match
> > ^$/home/user2/alice
> >
> > Unfortunately the search pattern doesnt work
> > here.
>
> No, because $ matches the end of the line only
> when it's at the end of the pattern.
>
> You already got one answer. Here's another:
>
> :/^$/+1g/pattern
>
> --
> JR
>
> --
> 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
>

Hi Taylor, hi Jean-Rene!

Thanks a lot for your help! :)

best regards,
mcc


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