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

Re: [Clip] duplicate lines leaving one

Expand Messages
  • buralex@gmail.com
    ... Problem I found with the above is must return to options to un-toggle Remove Duplicates if that s not the way you usually want to do it. Assuming you ve
    Message 1 of 5 , Oct 5, 2007
    • 0 Attachment
      hsavage <hsavage@...> said on Oct 05, 2007 9:16 -0400 (in part):
      > Dave wrote:
      > > Hi
      > > How do I remove duplicate lines and leave one,
      > > have clip for duplicate lines but it takes all ?
      > >
      > > Cardamar
      > > Various
      > > Zilent Zpott
      >
      > >
      > > I want to leave one of each.
      > > THANKYOU DAVE M
      >
      > Dave,
      >
      > Hugo's right, you don't need a clip to sort. Shift+Ctrl+X Sorts
      > Ascending, Shift+Ctrl+Y Sorts Descending. If nothing is selected this
      > will sort entire file, with selection made will sort only selection.
      > 'Options' below should be adjusted to suit before sorting.
      >
      > Go to 'View > Options > Tools', in Pro and Std, don't know about 'NT
      > Light', 2 checkboxes on the right allow you to customize sorting
      > parameters, Case Sensitive and Remove Duplicates.
      >
      > Perhaps you would include the clip you're trying to use in a reply,
      > might need editing.
      Problem I found with the above is must return to options to un-toggle
      Remove Duplicates if that's not the way you usually want to do it.

      Assuming you've already sorted the file (either ascending or descending)
      this one-liner regexp should do the trick (either as a clip or in the
      Find/Replace dialog with Regexp ticked):

      ^!replace "^(.*\R)(\1)+" >> "$1" rwais
      ie. replace (a line followed by a line terminator) followed by one or
      more occurrences of the same thing by just one occurrence

      Note: above will leave a doubled last line if (a) its a duplicate and
      (b) doesn't have a <CR><LF> after it. This could be tweaked but is left
      as an exercise for the user. ;-)

      With the blazing speed of Notetab's PCRE engine this is probably as fast
      and easy as it could be.

      Note: above requires Notetab 5.5 (possibly 5.4?) for the \R to match any
      <CR><LF> combo.
      If for some reason you haven't updated yet replace "\R" by "\r\n" or
      "\r?\n" in above if using Unix line endings.

      Regards ... Alec -- buralex-gmail
      --



      [Non-text portions of this message have been removed]
    Your message has been successfully submitted and would be delivered to recipients shortly.