Notepad++: Multiple words search in a file (may be in different lines)?

137,215

Solution 1

You need a new version of notepad++. Looks like old versions don't support |.

Note: egrep "CAT|TOWN" will search for lines containing CATOWN. (CAT)|(TOWN) is the proper or extension (matching 1,3,4). Strangely you wrote and which is btw (CAT.*TOWN)|(TOWN.*CAT)

Solution 2

<shameless-plug>

Search+ is a notepad++ plugin that does exactly this. You can download it from here and install it following the steps mentioned here

Feel free to post any issues/suggestions here.

</shameless-plug>

Solution 3

Possible solution

  1. In Notepad++ , click search menu, the click Find
  2. in FIND WHAT : enter this ==> cat|town
  3. Select REGULAR EXPRESSION radiobutton
  4. click FIND IN CURRENT DOCUMENT

Screenshot

Solution 4

If you are using Notepad++ editor (like the tag of the question suggests), you can use the great "Find in Files" functionality.

Go to SearchFind in Files (Ctrl+Shift+F for the keyboard addicted) and enter:

  • Find What = (cat|town)

  • Filters = *.txt

  • Directory = enter the path of the directory you want to search in. You can check Follow current doc. to have the path of the current file to be filled.

  • Search mode = Regular Expression

Share:
137,215

Related videos on Youtube

unirock
Author by

unirock

Updated on July 09, 2022

Comments

  • unirock
    unirock almost 2 years

    How can we perform multiple search for multiple words and the line containing them. These words can be in same or different lines. For example:

    1.The CAT goes up and down the ROAD.
    2. The DOG goes up and down the CITY.
    3. The HORSE goes up and down the TOWN.
    4. The DONKEY goes up and down the TOWN.

    Now, I wish to do a search for the lines containing CAT and TOWN in one shot. So, I would get the output as line 1, 3, 4 in sequence. That would be the same way we do in Unix (more file | egrep "CAT|TOWN").

    How can we do it in Notepad++??

  • unirock
    unirock about 12 years
    Thanks much Buddy!! (cat)|(town)....it worked pretty well...and easy to remember too !
  • Alex
    Alex over 9 years
    This looks to be outdated. New versions have support. see here: stackoverflow.com/a/14727514/265877
  • GroD
    GroD over 8 years
    amarghosch do you have a windows version of this plugin?
  • GroD
    GroD over 8 years
    i need a windows version of this plugin for Notepad++ v6
  • Chris Smith
    Chris Smith over 7 years
    It would be good if this appeared in the Plugin Manager within Notepad++ for easier install.