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

RE: (another) regexp: can this be done?

Expand Messages
  • jason
    ... Hash: SHA1 Michael .. you wrote .. ... it s times like these I m thankful for Perl ... will produce this is warning no 3 this is warning no 5 that was
    Message 1 of 19 , Mar 28, 2000
    • 0 Attachment
      -----BEGIN PGP SIGNED MESSAGE-----
      Hash: SHA1

      Michael .. you wrote ..

      > on a related note, let's have these sentences:
      >
      > this is warning no 3
      > this is warning no 5
      > this is notice no 9
      > this is warning no 8
      > this is error no 2
      >
      >i wasn't able to use any reasonable regexp in vim to be able to find
      >all matches _without_ the word 'warning' in it. is there any good to
      >specify such a regexp?

      it's times like these I'm thankful for Perl

      :perldo if( /this is \w+ no \d+/ && !/warning/) { s/this is/that was/ }

      will produce

      this is warning no 3
      this is warning no 5
      that was notice no 9
      this is warning no 8
      that was error no 2

      of course - if you're really just looking for any line without the word
      'warning' in it then it's even easier

      btw .. there must be a way of doing the same with a vim function - but
      I have no idea how to write those

      - --
      jason -- elephant@... --

      -----BEGIN PGP SIGNATURE-----
      Version: PGP 6.5.1i for non-commercial use <http://www.pgpi.com/>

      iQA/AwUBOOCnuTYpBpopJvWUEQKyoQCbBEpyRMH+M0UCG2Rwwctz+gXO+qMAni3Q
      jAGxfMW2g/m4XiZS4ciZf0NW
      =wg5O
      -----END PGP SIGNATURE-----
    • Moore, Paul
      From: jason [mailto:jason@bigpond.com] ... Am I missing something? ... Paul.
      Message 2 of 19 , Mar 29, 2000
      • 0 Attachment
        From: jason [mailto:jason@...]
        > > on a related note, let's have these sentences:
        > >
        > > this is warning no 3
        > > this is warning no 5
        > > this is notice no 9
        > > this is warning no 8
        > > this is error no 2
        > >
        > >i wasn't able to use any reasonable regexp in vim to be able to find
        > >all matches _without_ the word 'warning' in it. is there any good to
        > >specify such a regexp?
        >
        > it's times like these I'm thankful for Perl
        >
        > :perldo if( /this is \w+ no \d+/ && !/warning/) { s/this
        > is/that was/ }
        >
        > will produce
        >
        > this is warning no 3
        > this is warning no 5
        > that was notice no 9
        > this is warning no 8
        > that was error no 2
        >
        > of course - if you're really just looking for any line
        > without the word
        > 'warning' in it then it's even easier
        >
        > btw .. there must be a way of doing the same with a vim function - but
        > I have no idea how to write those

        Am I missing something?

        :v/warning/s/this is/this was/

        Paul.
      • Stephen P. Wall
        ... Cool - saw that in the docs long ago and forgot all about it. However, the original problem was to match lines of the form this is !(warning) no d + .
        Message 3 of 19 , Mar 29, 2000
        • 0 Attachment
          > From: "Moore, Paul" <Paul.Moore@...-it.com>
          > :v/warning/s/this is/this was/

          Cool - saw that in the docs long ago and forgot all about it.
          However, the original problem was to match lines of the form
          "this is !(warning) no \d\+". :v/warning/ could return a smaller
          set. I think in this particular instance, it's not a concern,
          but it is not a general solution to this type of problem. The
          issue has been raised before, and it seems that regex in it's
          current form simply cannot handle this type of expression.

          On a related note, it should not be terribly difficult to add
          a pattern of the form "endw\c\(hile\)" that equates to
          "endw\(h\(i\(le\=\)\=\)\=\)\=" (Courtesy Matthew Winn).
          Syntax highlighting already allows a similar spec -
          "syn keyword Item endw[hile]". Maybe someone more motivated then
          I could take a look at the code.

          --
          Free High Speed DSL Access:
          http://in.winfire.com/s/isapiEng.dll/wf.exe?cmd=rl&452,180045277&wf.exe
          ______________________________________________________________________
          ________ ______
          Stephen P. Wall Redcom Laboratories, Inc. / __ /\/ ___/\
          Steve_Wall@... One Redcom Center ___/ /\/ /_/ /\__\/
          (716) 924-7550 Victor, NY 14564 /_____/ /_______/ /
          x300 USA \_____\/\_______\/
        • Michal Vitecek
          ... vim-developers, could regexp be expanded to this feature? i learned ... i d really love to see this thing in, if it was possible. -- fuf ... BillGates
          Message 4 of 19 , Apr 6, 2000
          • 0 Attachment
            "Stephen P. Wall" <swall@...> wrote:
            >> From: "Moore, Paul" <Paul.Moore@...-it.com>
            >> :v/warning/s/this is/this was/
            >
            >Cool - saw that in the docs long ago and forgot all about it.
            >However, the original problem was to match lines of the form
            >"this is !(warning) no \d\+". :v/warning/ could return a smaller
            >set. I think in this particular instance, it's not a concern,
            >but it is not a general solution to this type of problem. The
            >issue has been raised before, and it seems that regex in it's
            >current form simply cannot handle this type of expression.

            vim-developers, could regexp be expanded to this feature? i learned
            :v/pattern/s/pattern2/pattern3/ might be used, but it certainly has
            _fewer_ options for use as regexp. possible use:

            :%s/this is !(warning) no\. ([0-9]+)/it was \1 and had number \2/g

            i'd really love to see this thing in, if it was possible.

            --
            fuf


            ------------------------------ na IRC -------------------------------------
            BillGates [bgates@...] has joined #LINUX
            ...
            mode/#linux [+b BillGates!*@*] by DoDad
            BillGates was kicked off #linux by DoDad (banned: We see enough of Bill
            Gates already.)
          • Matthew Winn
            ... Perl-compatible regular expressions which allow negative assertions are on the todo list. One of the main problems is reconciling Vim s use of ? as a
            Message 5 of 19 , Apr 6, 2000
            • 0 Attachment
              On Thu, Apr 06, 2000 at 03:59:09PM +0200, Michal Vitecek wrote:
              > >However, the original problem was to match lines of the form
              > >"this is !(warning) no \d\+". :v/warning/ could return a smaller
              > >set. I think in this particular instance, it's not a concern,
              > >but it is not a general solution to this type of problem. The
              > >issue has been raised before, and it seems that regex in it's
              > >current form simply cannot handle this type of expression.
              >
              > vim-developers, could regexp be expanded to this feature? i learned
              > :v/pattern/s/pattern2/pattern3/ might be used, but it certainly has
              > _fewer_ options for use as regexp. possible use:
              >
              > :%s/this is !(warning) no\. ([0-9]+)/it was \1 and had number \2/g
              >
              > i'd really love to see this thing in, if it was possible.

              Perl-compatible regular expressions which allow negative assertions
              are on the todo list. One of the main problems is reconciling Vim's
              use of ? as a backward search delimiter with Perl's use of ? for
              optional matching, non-greedy quantifiers and setting options within
              the expression.

              --
              Matthew Winn (matthew@...)
            • Arnaud Launay
              ... Another one is the implementation of these regexps in the code... I think using pcre would be helpful. For the ? problem... Defining a pcre mode ?
              Message 6 of 19 , Apr 6, 2000
              • 0 Attachment
                Le Thu, Apr 06, 2000 at 04:14:45PM +0100, Matthew Winn a écrit:
                > Perl-compatible regular expressions which allow negative assertions
                > are on the todo list. One of the main problems is reconciling Vim's
                > use of ? as a backward search delimiter with Perl's use of ? for
                > optional matching, non-greedy quantifiers and setting options within
                > the expression.

                Another one is the implementation of these regexps in the code...
                I think using pcre would be helpful. For the "?" problem...
                Defining a "pcre mode" ?

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