Search code examples
regexemeditor

Remove all lines does not contain in other file


I have file A 'Emails' with so many email , and file B 'Domain' with so many domain

Example File A 'Emails ':

ctv@ymail.com
kfi@aol.in
hi@axus.cc
0@gmail.com
igp@yahoo.com
encor@mail2.com
cjang@mail.com
vn@gmail.com
87@gmail.com
ee@maoyt.com

Example file B 'Domain'

@gmail.com
@yahoo.com

My expected result :

0@gmail.com
igp@yahoo.com
vn@gmail.com
87@gmail.com

is there a way to do with 2 file in emeditor .Thanks much


Solution

  • I would propose using the Join CSV function. @Abimanyu's regex method may work if you have less than 10 or so domains. More than that, it might take a while to process the data.

    To prepare the document for joining, right click on the CSV/Sort toolbar and edit the User-defined separated format to use @ as the delimiter.

    Customize window

    Now on both file A and file B, change the CSV mode to User-defined separated. On the CSV/Sort toolbar, there is a button called "Join CSV".

    Join CSV window

    Join CSV options:

    • Make sure the correct documents are selected
    • Key Column is the email domain columns
    • In the list at the bottom, select the output columns, which should be column 1 and 2 from file A

    Press the Join Now button, change CSV mode to Normal mode and you will get an output which looks like this:

    0@gmail.com
    igp@yahoo.com
    vn@gmail.com
    87@gmail.com