Search & Replace
-
Hi,
I am trying to replace code within a programme with thousands of lines and have been unsuccessful in all my attempts.
Here is an example of what I want to do
In the programme, there is a line with
INSTRUCTION MY_VARIABLE
where INSTRUCTION is an instruction (ex: mov, swap, xor, etc) , and therefore a fixed and known text to search for.
MY_VARIABLE, on the other hand, is a variable, and therefore can be any text.Please note that there is a “TAB” separating the two words INSTRUCTION and VARIABLE.
I intend to replace it with
INSTRUCTION FIXED_TEXT(MY_VARIABLE),
i.e., I keep INSTRUCTION, I keep VARIABLE, and I add a fixed text (FIXED_TEXT) before VARIABLE.
Additionally, VARIABLE will be enclosed in parentheses.How can I do this using Notepad++?
Thanks
-
@Jose-Ramalho said in Search & Replace:
How can I do this using Notepad++?
Regular Expression mode on the search and replace. But you are way too vague in your verbal descriptions for me to give any details on what the specific regex is.
Use the
</>
button, and enter some text that matches the pattern (even if you have to use fake words), and show two sets of data: the data you start with (“before”), and the data you want it converted into (“after”). Give more than one line of example, elsewise we’re likely to misunderstand.----
Useful References
-
Hello, @Jose-Ramalho, @peterjones and All,
@jose-ramalho, let’s suppose this INPUT text :
move $a swap $b, $c
Then :
-
Open the Replace dialog (
Ctrl + H
) -
Uncheck all box options
-
FIND
(?-s)^(.+)\t(.+)
-
REPLACE
\1 FIXED_TEXT \(\2\)
-
Select the
Regular expression
search mode -
Possibly, check the
Wrap around
option -
Click on the
Replace All
button
=> You should get the following OUTPUT text :
move FIXED_TEXT ($a) swap FIXED_TEXT ($b, $c)
This is just my first idea. Obviously, this requires some ajustements. See you later !
Best regards,
guy038
-