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.
I often forget this feature, but use it from time to time when updating XML and HTML files. I love Notepad++ One of the best, free text editors for windows.
I wish Microsoft would have learned by now to include these kinds of tools by default in notepad. Regular notepad is getting old and tired.
Notepad++ is also nice for syntax highlighting and line numbering, so coders will find it much more useful for designing web pages or coding in their favorite languages.
Hello DigiP,
I could not agree more with the fact that Notepad++ is one of the best if not the best text editor for Windows and with the fact that regular old notepad is old and washed up!
I am just getting into more coding and have definitely used Notepad++ a bit for specifically what you are mentioning such as syntax highlighting, line numbering, etc.
Anyhow thanks for taking the time to leave feedback.
Thanks.
alex
They have some great plugins for it from the SourceForge community too. Check out their HEX editor plugin. Comes in handy from time to time, as well as the Base64 decoder/encoder.
sourceforge.net/projects/npp-plugins/files/
Hello DigiP,
I just started using Notepad++ plugins a couple weeks ago and so far I have found them really useful. The one I use daily is the auto backup plugin. I actually have notes queued up to write an article about using that plugin to automatically backup Notepad++ files directly into Evernote so all of your Notepad++ files are automatically synced to the web for availability from any Internet connection.
Thanks again for the comment and feedback! It is always much appreciated.
Thanks.
alex
Is it possible to search a doc using multiple names in one string? Instead of typing each name then clicking find?
So I can copy and paste a huge list which will then highlight and remove any name it matches exactly?
Is there a separator I can use?
Hello Lust,
I am not sure I completely understand the question. What is an example of what you would be searching for? If you mean you want to search for “bob” and “tom” at the same time the answer is yes however I guess I am confused at what you are trying to do. What is the end result that you want? If you could provide a small example with data then I might be able to provide a solution.
If you already found a solution we would like to hear what it was so others might also be able to use the same solution.
Thanks.
alex
Excellent! HOW? I’ve found a way using WinMerge, but I have to continually make different files each time I do it.
I’m trying to search a huge list of names and remove them because it changes everyday. And instead of me pasting in toms name then searching him out in the list, then deleting him, I want to add ALL names I want to remove, at once. IT should then mark them with taht blue orb right? So at least I can run down the list and remove them easier.
List looks like this.
1. tom
2. jerry
3. tweety
4. bird
The search box will look something like this;
FIND: tom, jerry, tweety, bird, someothername, andanother, andanother, etc, etc…
Hello Lust,
If this is something that repeatedly happens I would suggest writing a little Ruby, PHP, or even Shell application that will automate this for you. It might run once every 24 hours and all you have to do is feed in the file of names and it could keep the growing list of names you are removing every time the larger file is processed. This way you would only have to add a name or even names each time and you would not catch yourself repeating the process each time. How many names are you talking about in the list? How many names are removed daily from the main list? It sounds like instead of doing this manually each and every time that doing something with a script might be the way to go. Is this a possibility for you? You could easily do something like you mention with SED, AWK, etc.
Thanks.
alex
I have also tried looking for one for weeks, the best I came up with was WinMerge.
Thousands and Thousands of names in the list, and I HAVE NO CLUE how many will be removed each day.
All I really want is a way to know which new names need to be removed.
The thing is, the main list stays the same, but the other list is added to each day. I just want the added names to be searched out, but I cannot know which names I already searched, and I don’t want to search the same names I did yesterday, everyday. There are far too many and continues to grow.
At least with WinMerge I can use the previous days file and make a new file with the newly updated list I need to use to remove names from our main list.
So its cool, if NP++ cant let me use multiple names at once that’s cool. At least I found a way with WinMege :D…
Thanks so much for your time in this, its greatly appreciated.
Hello Lust,
No worries on the time. I am always curious to see what type of solution we can come up with in situations like this. It sounds like you probably have a fairly decent method to accomplish your goal. I am curious about one more item though…. do you remove every name from the list every day? It almost sounds like (and from your example) that the new names you are removing are names that were not on the list previously. I guess I am still confused on if you remove all of those names then what is left? Are you simply trying to get rid of duplicates? If this is the case I could whip up a bash script quickly that would sort and filter out unique names. Sorry for all the questions but just want to make sure I fully understand the scenario. So new names are added daily and you just need to know what the new names added daily are?
Thanks.
alex
I’ll show you.
Let’s assume the numbers used below are names. This is the main list I will be removing names from. Let’s call the main list the “ACTIVE” users list.
(Note, these names are not in horizontal order like laid out below, they are on there own lines, just to save space on this post.)
ACTIVE users list.
1, 2, 3, 4, 5, 6, 7, 8, 9, 10
“DEACTIVE” users list.
Day 1: 3, 6
Now the ACTIVE users list looks like this
1, 2, 4, 5, 7, 8, 9, 10 (Notice 3 and 6 are now gone)
—————————————–
“DEACTIVE” users list.
Day 2: 3, 6, 1, 7, 9
Now the ACTIVE list looks like this
2, 4, 5, 8, 10 (Notice 1, 7, 9 are now gone.)
So and and so forth.
Notice that in the DEACTIVE list, there will always be the same names in it as the day before, while always being added to.
Each day there are new names to remove. But the list is sooo large that I don’t know which names I removed the previous day. I know it sounds easy to just remove the names from both lists right?
But I can’t because the new names added to the DEACTIVE list are added in an intertwined state. Meaning, EVERY username that gets added to the DEACTIVE list, may not go to the bottom, or top, they can go anywhere in between.
So lets say the original order of the DEACTIVE list is , 3, 6, 1, 7, 9…BUT on Day 3, user 8 must be removed, BUT in the DEACTIVE list I copy from, he ends up in between, 3 and 6.
So now the DEACTIVE list looks like this 3, 8, 6, 1, 7, 9 (Notice 8 is between 3 and 6 now? Instead of being added to the end of the previous days list after 9?
There is no ordering…Long story..
What I have a problem is, is remembering what names I searched for the previous day. Sure the examples above are easy enough, but that’s not the reality. They are names and very many thousands of them all mixed up.
Make sense?
Hello LUST,
Yeah it definitely makes sense. Thanks for writing that up.
I am not sure about completing this task with Notepad++ and I think developing a program to automate this task would be the best method.
It would be much easier to write a script that not only automates this process but also keeps a history of what has been done. Each day when you get the file you upload it via a small form and it completes the process and spits out the modified file in return. Each time the file is modified it would backup the previous version so you always have history and never lose any data by accident. You could write this in almost any language and it sounds as though it would really save you lots of time.
Thanks.
alex
So again, with WinMerge at least I can compare side by side which LINE changed in each file, that gives me an accurate match on who to remove without having to SEARCH THE WHOLE list again, everyday..:D Just wish I didn’t have to use WinMerge, searching out in Notepad++ is soo easy and well, I’m never out of it..I use it for everything..
Hello LUST,
Yeah Notepad++ is awesome and for that matter WinMerge is awesome as well. I would definitely suggest writing an application in something like Python or the like to do this task for you.
Thanks.
alex
Ya, wish i knew Python or had time to do it :D..I never have much time any day of the week :(
Thanks for everything mate, gave me some good ideas on the automation though. Maybe one day I’ll hire a programmer to do it for me ;)
Hello LUST,
Yeah no problem at all man.
If you are interested one of us could write that program for you. Send us an email using the contact form on this site and we could discuss details and what it would cost but I have a feeling its going to be much cheaper than you expect. Instead of discussing here though lets move it to email even if you are just curious what it would take.
Thanks.
alex
Hey,
Might be unrelated but I have a Q about find option in Notepad++.
First; it is really annoying me to select between -UP and -DOWN while searching. If you are in the middle of the document,you press Ctrl+F and then use F3 to move on but then boom search stops because you reached the file end. Cannot it just circulate without me telling “hey go up now”?
Second, when I highlight some text and press Ctrl-F I want the selected text to be placed in the search box..I mean isn’t that very obvioussss…Do I have to type in anything that I want to search (even looong variable definitions)
Notepad++ is a cool editor, so I believe there are workarounds for these two, which are just basic things, say in KDE or sth.
Let me know of your experience,
Thank!
Jake
Hello Jake,
Yeah I agree with the searching up/down however on the flip it can be useful at times depending on how large the document is and where you are trying to search. If you select “Wrap Around” it will search through the entire document from beginning to end no matter where you are in the document that is opened in Notepad++.
When I highlight text and hit control-F it does add the text to the search field so I am assuming you have some configuration setting that is stopping this for some reason.
Thanks.
alex