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

regexp help

Expand Messages
  • RICHARD PITMAN
    Apologies if this is a re-post, I think the first went to the wrong address... I have a fortran program in which there are two sorts of numbers, integers which
    Message 1 of 7 , Jul 30, 2013
    • 0 Attachment
      Apologies if this is a re-post, I think the first went to the wrong address...

      I have a fortran program in which there are two sorts of numbers,
      integers which are simply digits not followed by a period, and double
      precision numbers in the form 1.0D0, or more precisely \d\+\.\d\+D\d\+ I would like to search for the former, avoiding the latter.


      Any
      suggestions gratefully received!

      --
      --
      You received this message from the "vim_use" maillist.
      Do not top-post! Type your reply below the text you are replying to.
      For more information, visit http://www.vim.org/maillist.php

      ---
      You received this message because you are subscribed to the Google Groups "vim_use" group.
      To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@....
      For more options, visit https://groups.google.com/groups/opt_out.
    • Davido
      ... The Boolpat plugin can combine patterns with logical operator (and/or/not), it may help you : http://www.vim.org/scripts/script.php?script_id=3850 --
      Message 2 of 7 , Jul 30, 2013
      • 0 Attachment
        RICHARD PITMAN <richard.pitman3@...> wrote, on mar 30 jui 10:18 :

        > Apologies if this is a re-post, I think the first went to the wrong address...
        >
        > I have a fortran program in which there are two sorts of numbers,
        > integers which are simply digits not followed by a period, and double
        > precision numbers in the form 1.0D0, or more precisely \d\+\.\d\+D\d\+ I would like to search for the former, avoiding the latter.
        >
        >
        > Any
        > suggestions gratefully received!
        >

        The Boolpat plugin can combine patterns with logical operator
        (and/or/not), it may help you :

        http://www.vim.org/scripts/script.php?script_id=3850

        --
        Regards,

        Davido

        --
        --
        You received this message from the "vim_use" maillist.
        Do not top-post! Type your reply below the text you are replying to.
        For more information, visit http://www.vim.org/maillist.php

        ---
        You received this message because you are subscribed to the Google Groups "vim_use" group.
        To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@....
        For more options, visit https://groups.google.com/groups/opt_out.
      • kilter
        ... Many thanks Davido, This helps a little, except that it searches line wise and so ill miss instances of integers where they occur on the same line a a
        Message 3 of 7 , Jul 30, 2013
        • 0 Attachment
          > > I have a fortran program in which there are two sorts of numbers,
          >
          > > integers which are simply digits not followed by a period, and double
          >
          > > precision numbers in the form 1.0D0, or more precisely \d\+\.\d\+D\d\+ I would like to search for the former, avoiding the latter.
          >
          > >
          >
          > >
          >
          > > Any
          >
          > > suggestions gratefully received!
          >
          > >
          >
          >
          >
          > The Boolpat plugin can combine patterns with logical operator
          >
          > (and/or/not), it may help you :
          >
          >
          >
          > http://www.vim.org/scripts/script.php?script_id=3850
          >
          >
          >
          > --
          >
          > Regards,
          >
          >
          >
          > Davido

          Many thanks Davido,

          This helps a little, except that it searches line wise and so ill miss instances of integers where they occur on the same line a a double precision number

          --
          --
          You received this message from the "vim_use" maillist.
          Do not top-post! Type your reply below the text you are replying to.
          For more information, visit http://www.vim.org/maillist.php

          ---
          You received this message because you are subscribed to the Google Groups "vim_use" group.
          To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@....
          For more options, visit https://groups.google.com/groups/opt_out.
        • Marcin Szamotulski
          ... You can try something like this, though it is not perfect (since it matches every digit separately):
          Message 4 of 7 , Jul 30, 2013
          • 0 Attachment
            On 11:37 Tue 30 Jul , Davido wrote:
            > RICHARD PITMAN <richard.pitman3@...> wrote, on mar 30 jui 10:18 :
            >
            > > Apologies if this is a re-post, I think the first went to the wrong address...
            > >
            > > I have a fortran program in which there are two sorts of numbers,
            > > integers which are simply digits not followed by a period, and double
            > > precision numbers in the form 1.0D0, or more precisely \d\+\.\d\+D\d\+ I would like to search for the former, avoiding the latter.
            > >
            > >
            > > Any
            > > suggestions gratefully received!
            > >
            >
            > The Boolpat plugin can combine patterns with logical operator
            > (and/or/not), it may help you :
            >
            > http://www.vim.org/scripts/script.php?script_id=3850
            >
            > --
            > Regards,
            >
            > Davido
            >
            > --
            > --
            > You received this message from the "vim_use" maillist.
            > Do not top-post! Type your reply below the text you are replying to.
            > For more information, visit http://www.vim.org/maillist.php
            >
            > ---
            > You received this message because you are subscribed to the Google Groups "vim_use" group.
            > To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@....
            > For more options, visit https://groups.google.com/groups/opt_out.
            >

            You can try something like this, though it is not perfect (since it
            matches every digit separately):

            \d\+\&\(\d\+\.\d\+D\d\+\)\@!\&\(\d\+D\)\@!\&\(\d\+\.\d\+D\d*\)\@<!

            Regards,
            Marcin

            --
            --
            You received this message from the "vim_use" maillist.
            Do not top-post! Type your reply below the text you are replying to.
            For more information, visit http://www.vim.org/maillist.php

            ---
            You received this message because you are subscribed to the Google Groups "vim_use" group.
            To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@....
            For more options, visit https://groups.google.com/groups/opt_out.
          • Erik Christiansen
            ... When I apply this search: / v([ t]|^)[0-9]+ _s to this line: 123 123.0 123. 456 0.123 .123 789 it stops only at each integer. Is that close enough? (It
            Message 5 of 7 , Jul 30, 2013
            • 0 Attachment
              On 30.07.13 10:18, RICHARD PITMAN wrote:
              > Apologies if this is a re-post, I think the first went to the wrong address...
              >
              > I have a fortran program in which there are two sorts of numbers,
              > integers which are simply digits not followed by a period, and double
              > precision numbers in the form 1.0D0, or more precisely \d\+\.\d\+D\d\+
              > I would like to search for the former, avoiding the latter.

              When I apply this search:

              /\v([ \t]|^)[0-9]+\_s

              to this line:

              123 123.0 123. 456 0.123 .123 789

              it stops only at each integer. Is that close enough?
              (It includes leading space. But perhaps \@<= could fix that, if it's
              important?)

              I would have expected

              /\v[ \t^][0-9]+\_s

              to also match, but '^' isn't working for me as "start of line" in the
              character class. (It is only as first character in the class (Vim calls
              that a "collection"), that it would negate the class.)

              The regex has the benefit of being largely posix, just using vim's \_s
              as shorthand for (whitespace or EOL). (Most posix implementations have
              extensions, so why shouldn't vim?)

              Erik

              --
              In attempting to ride roughshod over 1170 written objections, a local
              government determination, a resident survey 94% against them, and years of
              protests, McDonald's is seeking to trash democracy, AFAICT. We do _not_ want
              them in our hills! BURGER OFF from Tecoma. See: http://www.burgeroff.org/
              and www.change.org

              --
              --
              You received this message from the "vim_use" maillist.
              Do not top-post! Type your reply below the text you are replying to.
              For more information, visit http://www.vim.org/maillist.php

              ---
              You received this message because you are subscribed to the Google Groups "vim_use" group.
              To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@....
              For more options, visit https://groups.google.com/groups/opt_out.
            • Charles Campbell
              ... Try... /
              Message 6 of 7 , Jul 30, 2013
              • 0 Attachment
                Erik Christiansen wrote:
                > 123 123.0 123. 456 0.123 .123 789
                Try...
                /\<-\=[0-9]\+\ze\_s

                Regards,
                Chip Campbell

                --
                --
                You received this message from the "vim_use" maillist.
                Do not top-post! Type your reply below the text you are replying to.
                For more information, visit http://www.vim.org/maillist.php

                ---
                You received this message because you are subscribed to the Google Groups "vim_use" group.
                To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@....
                For more options, visit https://groups.google.com/groups/opt_out.
              • Erik Christiansen
                ... That fails here, also matching the fractional parts of the non-integers. The tweak of Ben Fritz s regex, on his second thread on this topic, seems to
                Message 7 of 7 , Jul 30, 2013
                • 0 Attachment
                  On 30.07.13 10:25, Charles Campbell wrote:
                  > Erik Christiansen wrote:
                  > >123 123.0 123. 456 0.123 .123 789
                  > Try...
                  > /\<-\=[0-9]\+\ze\_s

                  That fails here, also matching the fractional parts of the non-integers.
                  The tweak of Ben Fritz's regex, on his second thread on this topic,
                  seems to perform better, matching only the integers.

                  Erik

                  --
                  If society fits you comfortably enough, you call it freedom.
                  - Robert Frost

                  --
                  --
                  You received this message from the "vim_use" maillist.
                  Do not top-post! Type your reply below the text you are replying to.
                  For more information, visit http://www.vim.org/maillist.php

                  ---
                  You received this message because you are subscribed to the Google Groups "vim_use" group.
                  To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@....
                  For more options, visit https://groups.google.com/groups/opt_out.
                Your message has been successfully submitted and would be delivered to recipients shortly.