simple wildcard search
-
I know this is simple, but I’m stuck.
I want to find any three characters before “[TW]” in my document. e.g.: abc[TW] or zxq[TW]
I cant get it to search for three of any character followed by [TW] -
What you are looking for is called “Regular Expression search”. You will find this as an option in NPP’s search dialog. For further information about Regular Expressions see this FAQ.
Your search term depends on what you want to do with your search. To simply find your pattern you may try
\b\w{3}\\[TW\\]
as search expression (don’t forget to select “Regular Expression” in search options). If you want do do something with the part before the[TW]
you could use\b\w{3}(?=\\[TW\\])
. This will select any three letters followed by[TW]
. If you want to do something with the[TW]
try(?<=\b\w{3})\\[TW\\]
. This will select[TW]
only if preceeded by three letters. -
@gerdb42 said in simple wildcard search:
\b\w{3}[TW]
Gerdb - thank you very much! This nails the problem, where I have to find a couple hundred of these in 4,000 lines. Much appreciated.
-
@gerdb42 said in simple wildcard search:
(?<=\b\w{3})[TW]
This one may be problematic with N++ because it starts off with a lookbehind.
Due to the nature of the way N++ conducts searches, I wouldn’t be confident in this one.
I’d go with one of the other suggestions.