Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I have a two lists of words, one per line, each list in a separate file and I need to do two things:

  1. Merge the two lists but excluding the duplicates.
  2. Remove all words, that are less than 5 characters long.

For example: First list:

apple
banana
orange

Second list:

apricot
avocado
lime

Merged list:

apple
banana
orange
apricot
avocado

How to do this task with Notepad++?

share|improve this question
    
If possible, this will be extremely difficult to achieve with Notepad++. Is there any reason thy you cannot use something more sophisticated? –  Dennis Nov 24 '11 at 16:19

1 Answer 1

up vote 3 down vote accepted

Merging:

The easiest way to merge two files is to copy and paste. Notepad++ has no build-in file merging feature.

You can, however, install a plugin for this. See Combining files in Notepad++.

Another solution would be the command line's copy. See Need to combine lots of files in a directory

Replacing line breaks:

Removing duplicates will be trickier than removing short words since Notepad++'s search does not search over multiple lines at once, so we will have to convert the line breaks into something else.

To achieve this, you can perform an Extended replace, finding all \r\n (DOS line break) and replacing them by # (or any other character that does not appear in your list).

If the last line was not blank, append a # to the end of the resulting string.

Removing duplicates:

Now perform a Regular expression replace, finding all ([^#]+)#(.*#)\1# and replacing them by \1#\2.

If there were duplicates in a single file, you might have to do that more than once.

Removing words of 4 or less characters:

This one is easy. Just perform a Regular expression replace, finding all #.?.?.?.?# and replacing them by #.

Line breaks:

Now you can get rid of the line break hack. Just perform an Extended replace, finding all # and replacing them by \r\n.

Finally, delete the last line as it will be blank.

share|improve this answer
    
Clunky fun effective. –  soandos Nov 24 '11 at 16:50

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.