I had a document the other day that I needed to search through on my Windows laptop and find specific number combinations that started with a specific three digits and ended with another digit. For example I had a list of thousands of numbers and needed to find any number that matched 333xxx4 where the xxx could be any number combination. At first I wasn’t sure what application I should use on Windows but then I remembered that Notepad++ had regular expression search and replace support. Below is an example of searching for the combination I mention above along with a list of other regular expressions that can be used for matching variables in documents opened with Notepad++.
Locate Specific Number Combinations Using Notepad++:
First I will explain how I used Notepad++ to find any combination of number matching 333xxx4 in a list o thousands of numbers. I opened the list of numbers in Notepad++, clicked Search in the top navigation menu, and then selected Find in the drop down menu which will open the Find window as displayed in the below image.
Notepad++ Find Window:
There are a couple important items to notice in the above image. The first thing to notice is the Search Mode configuration which will need to have the radio button for “Regular expression” selected if you want to use the various Regular Expressions that Notepad++ offers. Then notice how in the “Find what:” text box I entered “333…4” which will match any number that begins with “333” and ends with “4”. This search would match examples that include “3331234”, “3333334”, “333abc4”, and “3330124”. You can use the same regular expressions when using the Notepad++ “Find and Replace” function as well. The option to use Regular Expressions with Notepad++ makes the application a really powerful tool to use on Windows. Below is a list of other Regular Expressions that can be used with Notepad++.
Notepad++ Regular Expressions:
- . Matches any character
- ( This marks the start of a region for tagging a match; so what's inside ( ) you can use in "replace with" using \\1, \\2 etc.
- ) This marks the end of a tagged region.
- \\n Where n is 1 through 9 refers to the first through ninth tagged region when replacing. For example, if the search string was Fred([1-9])XXX and the replace string was Sam\\1YYY , when applied to Fred2XXX this would generate Sam2YYY .
- \\< This matches the start of a word using Scintilla's definitions of words.
- \\> This matches the end of a word using Scintilla's definition of words.
- \\x This allows you to use a character x that would otherwise have a special meaning. For example, \\[ would be interpreted as [ and not as the start of a character set.
- [...] This indicates a set of characters, for example, [abc] means any of the characters a, b or c. You can also use ranges, for example [a-z] for any lower case character.
- [^...] The complement of the characters in the set. For example, [^A-Za-z] means any character except an alphabetic character.
- ^ This matches the start of a line (unless used inside a set, see above).
- $ This matches the end of a line.
- * This matches 0 or more times. For example, Sa*m matches Sm , Sam , Saam , Saaam and so on.
- + This matches 1 or more times. For example, Sa+m matches Sam , Saam , Saaam and so on.
If you need to find specific patterns in various file formats on Windows computers then Notepad++ is one of the more powerful tools available to you. It can take a little bit of time to get used to using Notepad++ on Windows however once you have started using the Regular Expressions capabilities it will be hard to live without the functionality.