Proximity Search in a Document to Find Words Based on Distance

0 Comments
Editor Ratings:
User Ratings:
[Total: 0    Average: 0/5]




This article covers how to perform proximity search in a document. This proximity search helps to find words in a document within the distance specified by you. So, let’s say a word “software” exists after every 4th, 8th, 9th, or 12th position of a word “free” in a text document. But, you need to search for the word “software” only on every 8th position of “free” word in that document, then with the help of proximity search technique, you can set the condition to find/highlight that word for every 8th position only. No matter how many times the word has existed in the entire document, it will be highlighted based on the condition set by you. This way the search is refined and you get more accurate results. While regular search feature of a software highlights the specified word everywhere in the document, this proximity search gives only a unique result based on the specified condition.

This article is focused on performing the proximity search in a text document (*.txt). For that, I have covered some very good and free software here. These software are also handy to open and edit text files and do other things.

Let’s check these software to perform proximity search in a text document.

Option 1: Use Notepad++ To Perform Proximity Search in a Document

Notepad++ is an advanced text and source code editor software. It also comes with a lot of plugins to perform tasks like remotely collaborate on a document, create, delete and edit GitHub gists, preview HTML in Notepad++, etc. Proximity search can also be performed in Notepad++. The good thing is you don’t have to use some plugin to perform this task. Notepad++ supports regular expression search in a document. You can use that feature and perform proximity search in a document. For this:

  • Open a text or some other supported document in Notepad++.
  • Use ‘Ctrl+F‘ to open the search box.
  • Select Regular expression radio button in the “Search Mode“. After that, add regular expression which is based on proximity search. It would be like: "\bFIRSTWORD\b (?:\w+[- ]){5}\bSECONDWORD\b". You can replace FIRSTWORD with the word available in your document, SECONDWORD with another word present in your document, and “5” with any other number. That number indicates the distance between first and second words.

proximity search using notepad++

Use Enter key or Find Next button and those words based on proximity search are highlighted.

Option 2: Start Proximity Search in a Document Using Free DocFetcher

DocFetcher is actually a very good and open source desktop search software. It lets you find files based on the specified word and look for that particular word in those files without opening them. The good thing is proximity search is also available. For that, you need to:

  • Download, install this software and open its interface. Java is needed to run this software. So, you must also install Java (if not already). There are document types (EPUB, DOCX, DOC, etc.) already selected on the left section of its interface so you don’t need to select file types to see the list of documents on its interface. Also, you can set minimum and maximum file size to filter the list of documents.
  • Right-click on Search scope box (on the bottom left section) → Create Index From → and select Folder option. This will help you add that folder where your documents are stored.
  • On the search box, add “FIRSTWORD SECONDWORD”~Number. Here, the number indicates the gap between the first and second word to perform the proximity search.

DocFetcher- interface

Press Enter key. This will filter the list of documents. When you will select a document, it will show the content and highlight the words set by you for proximity search.

Option 3: Free EditPad Lite Software to Perform Proximity Search in a Text Document

EditPad Lite (free for personal use) is also a handy option to perform proximity search in a text document. Its interface and features are similar to Notepad++. You can open multiple text documents on its interface in different tabs. To start proximity search, it also supports regular expression.

EditPad Lite

  • Open its interface and a document.
  • Turn on Regex option.
  • In the search box, add the regular expression similar to the example given in option 2. It would be: \bFIRSTWORD\b (?:\w+[- ]){6}\bSECONDWORD\b. Replace first and second word options with words present in the document and “6” with any distance of your choice.

Use search arrows or Enter key and it will highlight those words in the document.

Option 4: Free Geany Software with Proximity Search Support

Like Notepad++ and EditPad Lite, Geany software is also handy to do proximity search in a text document. It also provides regular expression feature for search.

Install and then run this software. When you have opened some text or another supporting document on its interface, use “Ctrl+F” to open the Find box. After that, select “Use regular expressions” option and then add the regular expression based on your proximity search.

Geany- interface

When you will press Enter, you will see that it is highlighting the result within the document.

The Conclusion:

These are some very good software to do proximity search in a text document and find words based on the gap or distance. Among all these software, “Notepad++” is my favorite software on this list. This is my favorite text editor for numerous reasons and finding proximity search is pretty easy. You may try all these software and then use the best one for you.

Editor Ratings:
User Ratings:
[Total: 0    Average: 0/5]
Works With: Windows
Free/Paid: Free