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

105484Re: how to match the space Not begin from the start-of-line

Expand Messages
  • A. S. Budden
    Jul 1, 2009
      2009/7/1 ginkgo <mydorado@...>:
      > On Jul 1, 5:47 pm, "A. S. Budden" <abud...@...> wrote:
      >> 2009/7/1 ginkgo <mydor...@...>:
      >> > Hello everyone,
      >> >  I want to know how to match the space that is not in the start of
      >> > the line.
      >>
      >> > for example
      >> >    sss sss
      >> > ^^^^   ^
      >> > I just match the second part of the sample.
      >> > Can anyone help me?
      >>
      >> How about:
      >>
      >> /^\s\+\S\+\zs\s
      >>
      >> /    - Search
      >> ^    - Start of the line
      >> \s\+ - One or more spaces (replace \+ with * if you don't mind whether
      >> there are spaces)
      >> \S\+ - One or more non-space characters
      >> \zs  - Start the match from here (so ignore everything before)
      >> \s   - A space
      >>
      >> Al
      >
      > Thank for quick reply,  you pattern work for this case.
      > I think I do not say clear, the other example
      >    sss  sss   ss
      > ^^^^   ^^   ^^  ^^
      >
      > just match the second part. I want to match the 2,3,4 part

      Ah, sorry, I misunderstood. I think Tim has posted a good solution,
      but another option would be:

      /\S\@<=\s

      \S - Non space
      \@<= - Match with zero width if the \S is present
      \s\+ - The spaces (or tabs) that you're looking for.

      This will match any space characters that are preceded by something
      that isn't a space character. You can probably also do:

      \S\zs\s\+

      Al

      --~--~---------~--~----~------------~-------~--~----~
      You received this message from the "vim_use" maillist.
      For more information, visit http://www.vim.org/maillist.php
      -~----------~----~----~----~------~----~------~--~---
    • Show all 7 messages in this topic