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

Re: regexp and matchstr()

Expand Messages
  • Mikolaj Machowski
    ... Hello, This is a part of mail from Halim. It get to me probably by mistake: HALIM,SALMAN (HP-NewJersey,ex2) Here s a nice and ugly
    Message 1 of 3 , Sep 9 4:23 AM
    • 0 Attachment
      Dnia Tuesday 09 of September 2003 10:49, Malte Neumann napisaƂ:
      > Hi,
      >
      > I have two questions:
      >
      > 1.
      > why don't I get a match when using a 'complicated' pattern in the
      > function match/matchstr?
      >
      > I have the following line:
      > for ( loop=0; loop<40; loop++)
      >
      > If I do:
      > :echo matchstr(forline,"loop=0")
      >
      > I get
      > loop=0
      >
      > But if I do:
      > :echo matchstr(forline,"\(( *\)\zs\l*\>")
      >
      > I get no match, eventhough a search (/\(( *\)\zs\l*\>) on this line
      > matches loop.
      >
      Hello,

      This is a part of mail from Halim. It get to me probably by mistake:

      "HALIM,SALMAN (HP-NewJersey,ex2)" <salman@...>

      Here's a nice and ugly snippet:

      let test='for ( int i = 0; i < 10; i++ )'
      let test='for ( i = 0; i < 10; i++ )'
      let
      expression='for\s*(\s*\(\w\+\(\s\+\)\)\?\(\w\+\)\s*=\s*\(\d\+\)\s*;.\{-}\(\d
      \+\)\(.*\)'
      echo 'Type : ' . substitute(test, expression, '\1', '')
      echo 'Variable : ' . substitute(test, expression, '\3', '')
      echo 'Start : ' . substitute(test, expression, '\4', '')
      echo 'End : ' . substitute(test, expression, '\5', '')
      echo 'Remainder: ' . substitute(test, expression, '\6', '')


      --
      LaTeX + Vim = http://vim-latex.sourceforge.net/
      Vim-list(s) Users Map: (last change 26 Aug)
      http://skawina.eu.org/mikolaj/vimlist
      Are You There?
    Your message has been successfully submitted and would be delivered to recipients shortly.