Re: Matching JUST the nth occurence of a text in a line

2006-12-01 Thread zzapper
A.J.Mechelynck [EMAIL PROTECTED] wrote in news:[EMAIL PROTECTED]: Bill McCarthy wrote: On Thu 30-Nov-06 11:49pm -0600, Peter Hodge wrote: --- Bill McCarthy wrote: On Thu 30-Nov-06 10:24pm -0600, Peter Hodge wrote: --- Bill McCarthy wrote: On Thu 30-Nov-06 9:20pm -0600, Peter Hodge wrote:

Re: Matching JUST the nth occurence of a text in a line

2006-12-01 Thread Charles E Campbell Jr
Peter Hodge wrote: Try: /^.\{-}home.\{-}\zshome for your reference: \{-} makes the '.' match as little as possible \zs makes the search match begin at this point in the pattern To generalize to the n-th occurrence: (put the qty of skipped matches in N)

Re: Matching JUST the nth occurence of a text in a line

2006-12-01 Thread mzyzik
All, I am puzzled by a slightly more complicated version: how to match a '%' character following the 2nd occurrence of home? --Matt On Fri, Dec 01, 2006 at 09:09:17AM -0500, Charles E Campbell Jr wrote: Peter Hodge wrote: Try: /^.\{-}home.\{-}\zshome for your reference:

Re: Matching JUST the nth occurence of a text in a line

2006-12-01 Thread Charles E Campbell Jr
[EMAIL PROTECTED] wrote: I am puzzled by a slightly more complicated version: how to match a '%' character following the 2nd occurrence of home? /^.\{-}\%(home.\{-1,}\)\{N}home.\{-}\zs% where N is 1 for the 2nd occurrence (N is 2 for the third occurrence, etc). This pattern

Re: Matching JUST the nth occurence of a text in a line

2006-12-01 Thread Bill McCarthy
On Fri 1-Dec-06 1:59am -0600, A.J.Mechelynck wrote: He gave it. In the above case, you highlight not only the 2nd occurrence but also the 4th, 6th, etc. Of course. I was so focused on (1) the second on the line and (2) the shortest match first algorithm of non-greedy constructs (which

Re: Matching JUST the nth occurence of a text in a line

2006-12-01 Thread mzyzik
On Fri, Dec 01, 2006 at 10:34:14AM -0500, Charles E Campbell Jr wrote: [EMAIL PROTECTED] wrote: I am puzzled by a slightly more complicated version: how to match a '%' character following the 2nd occurrence of home? /^.\{-}\%(home.\{-1,}\)\{N}home.\{-}\zs% This pattern doesn't

Re: Matching JUST the nth occurence of a text in a line

2006-12-01 Thread Charles E Campbell Jr
[EMAIL PROTECTED] wrote: On Fri, Dec 01, 2006 at 10:34:14AM -0500, Charles E Campbell Jr wrote: [EMAIL PROTECTED] wrote: I am puzzled by a slightly more complicated version: how to match a '%' character following the 2nd occurrence of home?

Re: Matching JUST the nth occurence of a text in a line

2006-12-01 Thread Yakov Lerner
On 12/1/06, Bill McCarthy [EMAIL PROTECTED] wrote: One might think so, but also note: :help non-greedy I don't have tag 'non-greedy' in the help. I have vim 7.9.164 from svn. Where do I get more updated helpfiles ? Yakov

Re: Matching JUST the nth occurence of a text in a line

2006-12-01 Thread Yakov Lerner
On 12/2/06, Yakov Lerner [EMAIL PROTECTED] wrote: On 12/1/06, Bill McCarthy [EMAIL PROTECTED] wrote: One might think so, but also note: :help non-greedy I don't have tag 'non-greedy' in the help. I have vim 7.9.164 7.0.164, sorry, not 7.9.164. Still, where do I get more updated

Re: Matching JUST the nth occurence of a text in a line

2006-12-01 Thread A.J.Mechelynck
Yakov Lerner wrote: On 12/1/06, Bill McCarthy [EMAIL PROTECTED] wrote: One might think so, but also note: :help non-greedy I don't have tag 'non-greedy' in the help. I have vim 7.9.164 from svn. Where do I get more updated helpfiles ? Yakov By ftp:

Re: Matching JUST the nth occurence of a text in a line

2006-12-01 Thread Bill McCarthy
On Fri 1-Dec-06 7:19pm -0600, Yakov Lerner wrote: On 12/1/06, Bill McCarthy [EMAIL PROTECTED] wrote: One might think so, but also note: :help non-greedy I don't have tag 'non-greedy' in the help. I have vim 7.9.164 from svn. Where do I get more updated helpfiles ? I see Tony already

Re: Matching JUST the nth occurence of a text in a line

2006-11-30 Thread Bill McCarthy
On Thu 30-Nov-06 6:31pm -0600, zzapper wrote: Hi given a sample text below home home gg home xxx home ggg ggg home home home home How do you match JUST the second home in any of the above lines (ie avoid greediness) /home.\{-}\zshome -- Best regards, Bill

Re: Matching JUST the nth occurence of a text in a line

2006-11-30 Thread Peter Hodge
Hello, Try: /^.\{-}home.\{-}\zshome for your reference: \{-} makes the '.' match as little as possible \zs makes the search match begin at this point in the pattern regards, Peter --- zzapper [EMAIL PROTECTED] wrote: Hi given a sample text below home home gg home xxx home

Re: Matching JUST the nth occurence of a text in a line

2006-11-30 Thread Bill McCarthy
On Thu 30-Nov-06 9:20pm -0600, Peter Hodge wrote: Try: /^.\{-}home.\{-}\zshome for your reference: \{-} makes the '.' match as little as possible \zs makes the search match begin at this point in the pattern One might think so, but also note: :help non-greedy In particular,

Re: Matching JUST the nth occurence of a text in a line

2006-11-30 Thread Peter Hodge
--- Bill McCarthy [EMAIL PROTECTED] wrote: On Thu 30-Nov-06 9:20pm -0600, Peter Hodge wrote: Try: /^.\{-}home.\{-}\zshome for your reference: \{-} makes the '.' match as little as possible \zs makes the search match begin at this point in the pattern One might think

Re: Matching JUST the nth occurence of a text in a line

2006-11-30 Thread Bill McCarthy
On Thu 30-Nov-06 10:24pm -0600, you wrote: --- Bill McCarthy [EMAIL PROTECTED] wrote: On Thu 30-Nov-06 9:20pm -0600, Peter Hodge wrote: Try: /^.\{-}home.\{-}\zshome for your reference: \{-} makes the '.' match as little as possible \zs makes the search match begin at

Re: Matching JUST the nth occurence of a text in a line

2006-11-30 Thread Peter Hodge
--- Bill McCarthy [EMAIL PROTECTED] wrote: On Thu 30-Nov-06 10:24pm -0600, you wrote: --- Bill McCarthy [EMAIL PROTECTED] wrote: On Thu 30-Nov-06 9:20pm -0600, Peter Hodge wrote: Try: /^.\{-}home.\{-}\zshome for your reference: \{-} makes the '.' match as

Re: Matching JUST the nth occurence of a text in a line

2006-11-30 Thread Bill McCarthy
On Thu 30-Nov-06 11:49pm -0600, Peter Hodge wrote: --- Bill McCarthy wrote: On Thu 30-Nov-06 10:24pm -0600, Peter Hodge wrote: --- Bill McCarthy wrote: On Thu 30-Nov-06 9:20pm -0600, Peter Hodge wrote: Try: /^.\{-}home.\{-}\zshome for your reference: \{-} makes the '.' match as

RE: Matching JUST the nth occurence of a text in a line

2006-11-30 Thread Chuck Mason
Am I the only one amused that /homeCRn does nearly the same thing? I mean, I suppose you could be doing operations on your search but couldn't you equally just ayw and do stuff there? Besides \{-}\zs takes too long to type :) -Original Message- From: Bill McCarthy [mailto:[EMAIL

Re: Matching JUST the nth occurence of a text in a line

2006-11-30 Thread A.J.Mechelynck
Bill McCarthy wrote: On Thu 30-Nov-06 11:49pm -0600, Peter Hodge wrote: --- Bill McCarthy wrote: On Thu 30-Nov-06 10:24pm -0600, Peter Hodge wrote: --- Bill McCarthy wrote: On Thu 30-Nov-06 9:20pm -0600, Peter Hodge wrote: Try: /^.\{-}home.\{-}\zshome for your reference: \{-} makes