Loading ...
Sorry, an error occurred while loading the content.

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

Expand Messages
  • Charles E Campbell Jr
    Dec 1, 2006
    • 0 Attachment
      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)

      /^.\{-}\%(home.\{-1,}\)\{N}\zshome

      So, for the 2nd home: let N=1.

      Regards,
      Chip Campbell
    • Show all 20 messages in this topic