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

Trying to find lines with same first 30 chars

Expand Messages
  • mycroftj
    I know that ^(.* R)( 1)+ will find (sorted) duplicate lines but I want to find lines that only match the first 30 characters. I thought ^(.{30})( 1)+ would
    Message 1 of 3 , Oct 6, 2009
    • 0 Attachment
      I know that ^(.*\R)(\1)+ will find (sorted) duplicate lines but I want to find lines that only match the first 30 characters.

      I thought ^(.{30})(\1)+ would work, but it does not.
      When I do a test and use ^(.{2}) it matches the first two chars on line one, then the next two chars and stops.

      What am I not understanding?

      Thanks!

      Joy
    • Sheri
      ... Sounds like you need to match not only the first 30 characters, but also the rest of the line. Then after that line, continue matching subsequent whole
      Message 2 of 3 , Oct 6, 2009
      • 0 Attachment
        --- In ntb-scripts@yahoogroups.com, "mycroftj" <mycroftj@...> wrote:
        >
        > I know that ^(.*\R)(\1)+ will find (sorted) duplicate lines but I want to find lines that only match the first 30 characters.
        >
        > I thought ^(.{30})(\1)+ would work, but it does not.
        > When I do a test and use ^(.{2}) it matches the first two chars on line one, then the next two chars and stops.
        >
        > What am I not understanding?
        >
        > Thanks!
        >
        > Joy
        >

        Sounds like you need to match not only the first 30 characters, but also the rest of the line. Then after that line, continue matching subsequent whole lines where the first 30 characters are the same as the ones on the starting line. Untested, but I think this should work:

        ^(.{30}).*\R(\1.*\R)+

        Regards,
        Sheri
      • mycroftj
        Sheri Thank you. You are correct and your suggestion works perfectly. I d never have guessed that one. Joy
        Message 3 of 3 , Oct 6, 2009
        • 0 Attachment
          Sheri

          Thank you. You are correct and your suggestion works perfectly.
          I'd never have guessed that one.

          Joy



          --- In ntb-scripts@yahoogroups.com, "Sheri" <silvermoonwoman@...> wrote:
          >
          > Sounds like you need to match not only the first 30 characters, but also the rest of the line. Then after that line, continue matching subsequent whole lines where the first 30 characters are the same as the ones on the starting line. Untested, but I think this should work:
          >
          > ^(.{30}).*\R(\1.*\R)+
          >
          > Regards,
          > Sheri
          >
          >
          > --- In ntb-scripts@yahoogroups.com, "mycroftj" <mycroftj@> wrote:
          > >
          > > I know that ^(.*\R)(\1)+ will find (sorted) duplicate lines but I want to find lines that only match the first 30 characters.
          > >
          > > I thought ^(.{30})(\1)+ would work, but it does not.
          > > When I do a test and use ^(.{2}) it matches the first two chars on line one, then the next two chars and stops.
          > >
          > > What am I not understanding?
          > >
          > > Thanks!
          > >
          > > Joy
          > >
          >
        Your message has been successfully submitted and would be delivered to recipients shortly.