Searchin with wildcards
-
Hi.
Well, I dont know if this could be possible , but I’d like to search and replace arguments with anothers using wildcards.
For example, I’d like to find all the worlds between symbols [] and replace them with others or simply erase them.
So if my text file have ocurrences like [one] , [two], [three], etc. I’d like to replace all these at the same time with [nothing] or simply search all the worlds that are between [] and erase them including the [] symbols.Any idea?
Thanks in advance and apologize for my english.
-
Hi, @fernando-conti,
Very easy with regular expressions, indeed !
-
Open your file, in Notepad++
-
Move back at the very beginning (
CTRL + Origin
) -
Open the Find / Replace dialog (
Ctrl + H
) -
Check the Regular expression search mode
-
Check, if necessary, the Match case option
-
In the Find what: zone, type the regex
\[.+?\]
-
In the Replace with: zone, simply type the text that must replace all the
[......]
zones or leave it empty if you prefer to delete the[......]
zones -
Click on the Replace All button
Et voilà,
Notes :
-
As the symbols
[
and]
have special meaning in regular expressions, they have to be escaped, both, to be considered as literal characters -
The part
.+?
stands for the smallest range of characters, between the symbols[
and]
For instance, given the example text, below :
This is a [123] test for searching [abc] all the [.......] zones !
The regex :
SEARCH
\[.+?\]
REPLACE
Leave EMPTY
modifies the text as below :
This is a test for searching all the zones !
If the regex was
\[.+\]
, it would have select the largest zone between the symbols[
and]
, that it to say, the string “[123] test for searching [abc] all the [.......]
”, in our example. Certainly not what you’re looking for !Best Regards,
guy038
-