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

Re: perl x modifier regex ?

Expand Messages
  • Marc Chantreux
    ... Ok. There is no solution so i decided to write functions that returns RE chunks in vimfiles/autoload/RE{,/XML}.vim 2 advantages to proceed like this : -
    Message 1 of 4 , Jan 2, 2007
    • 0 Attachment
      A.J.Mechelynck a écrit :
      > You can always add one or more lines of comments above or below the
      > line including the pattern in a Vim script, or even, in most cases, at
      > the end of the line; but IIUC you cannot insert comments in the middle
      > of a pattern.
      Ok. There is no solution so i decided to write functions that returns RE
      chunks in vimfiles/autoload/RE{,/XML}.vim

      2 advantages to proceed like this :
      - readable.
      - reusable

      For Exemple, the way to match an XML tag is almost a FAQ on this list.
      Why not provide something like the awsome Regexp::Common perl module ?

      I wrote :

      function RE#Magic()
      return '\v'
      endfunction

      function RE#Submatch( regExp )
      return '('.a:regExp.')'
      endfunction

      function RE#OptionnalSubmatch( regExp )
      return '(%('.a:regExp.'){0,1})'
      endfunction

      function RE#XML#Ident()
      return '[[:alpha:]][[:alnum:]]*'
      endfunction

      function RE#XML#NSIdent()
      let ident = RE#XML#Ident()
      " a namespace
      " : separator
      " a tagname
      return
      \ RE#OptionnalSubmatch( ident ) .
      \ RE#OptionnalSubmatch( ':' ) .
      \ RE#OptionnalSubmatch( ident ) .
      endfunction

      Comments and advices about it would be really nice.

      > To use perl regexps, you can of course embed perl statements in a
      > perl-enabled version of Vim; but of course at the cost of making the
      > script less portable.
      I gave this solution away a long time ago. I think that all alien
      langages (langages other than viml) is the worst idea of the vim
      developper team.

      regards
      mc
    Your message has been successfully submitted and would be delivered to recipients shortly.