Find and Replace? - Finding numbers and multiplying then
-
It looks simple but a couldn’t find any help.
I have a script with several lines with the same command and different numbers, for example:
“CommandEx” “20”
.
.
“CommandEx” “35”
.
.
“CommandEx” “26”
…But now I need to multiply this numbers by a single multiplier, example: 20 * 4, 35 * 4, 26 * 4… resulting 80, 140, 104…
“CommandEx” “80”
.
.
“CommandEx” “140”
.
.
“CommandEx” “104”
…I found a lot of regular expressions to “find” but none to “replace” that could help me. The script have more then a hundred of this command and others commands to multiply and do others basic arithmetic operations individually, and I really need to replace them faster.
I am open to any solutions.
-
Can’t do it with regular expression replacement. It’s not a supported operation.
-
Do you think it’s possible to do it any other way?
-
@Murillo-Noleto said:
any other way?
There are many ways, not all will be using NPP (Notepad++) though. A programming language, you would need to learn it first or find someone willing to write a program for you. Python Script runs within NPP, however still a learning process.
Excel is good at parsing text files and can easily perform calculations. In fact all you’d need to do is load the text file into Excel, then use a find command on each line (set it up on one line and copy it to all others). If it found the right text it would then multiply the number on that line as well. Then you write out the resulting text.
Terry
-
Thank you. I really forgot about Excel, can’t believe that haha. But it was really hard, since Excel’s ways to optimise the script made it so that some symbols disappear. So there I was again, no time for that.
So what I did was actually really use Find and Replace on Notepad++. There were severals commands and a hundred lines for every command but the numbers on them were a few, well, compared to the rest. Then I opened a new note and wrote a “Find” to find all the possible numbers for a command and “replace” with the correct ones. It toke a long time. After that I just “found” and “replaced” the written command name by another one, and repeated that for all the commands.
In the end I had all the notes for every command with a long find and replace in each one. It took me two hours to do the first and a few minutes to make the rest of it.