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

Re: Explanation on \zs

Expand Messages
  • Yongwei Wu
    ... Please notice the Vim mailing list requires bottom-posting. My understanding of what happens in your matching: - . is matched first; - For each match of
    Message 1 of 6 , Mar 1, 2008
    • 0 Attachment
      On 29/02/2008, ACR <anith.ravi@...> wrote:
      >
      > Thanks a lot Tony..
      > I am trying out this in the :substitute command. For eg.
      > I can use
      > :%s/\(foo.*\)\@<=./-/g
      > To replace
      > "Hello, this string is foo. Please check" to "Hello, this string is
      > ---------------------------------"
      > But, am not able to explain the behaviour. How does this command
      > work?

      Please notice the Vim mailing list requires bottom-posting.

      My understanding of what happens in your matching:

      - "." is matched first;
      - For each match of "." (i.e., every character), check whether "foo.*"
      is before it;
      - If "foo.*" is before it, replace "." with "-".

      So it is a slow matching process, just as the help says.

      > Also, would like to know who \zs can replace \@<= in this command and
      > the result be the same.

      I think you just had an example where \zs cannot replace \@<=. The
      similar substitution "%s/\(foo.*\)\zs./-/g" work differently: it will
      match "foo.*.", and replace the last "." with "-".

      Best regards,

      Yongwei

      --
      Wu Yongwei
      URL: http://wyw.dcweb.cn/

      --~--~---------~--~----~------------~-------~--~----~
      You received this message from the "vim_use" maillist.
      For more information, visit http://www.vim.org/maillist.php
      -~----------~----~----~----~------~----~------~--~---
    Your message has been successfully submitted and would be delivered to recipients shortly.