Very new to notepad++
-
You are expected to modify what the script searches for, and what the script replaces, so that it will give you the results necessary. We are not a free custom data manipulation outsource facility.
The example script shown in the FAQ is only an example, not a customized script for your specific situation. The intention is that users will modify the script in the FAQ to search for the text they want to match, and to output the text they want to replace it with.
For your level of skill, I would suggest doing things in multiple passes, one for each attribute that you want to change. I will show you an example of how to manipulate it for one – your
DamageCapacity="50"
and similar (ie, any that are attribute ofDamageCapacity
with an arbitrary number inside the quotes). The process that you need to go through:- Ask yourself, “what am I searching for?”:
- ANSWER = “I want
DamageCapacity
followed by equals sign, with a number in quotes”.
- ANSWER = “I want
- Ask yourself, “how do I translate that into a regular expression?”
- ANSWER =
DamageCapacity="(\d*\.?\d+)"
- Note: I used the floating point definition of a number, as derived from the other example I pointed you to earlier, so that way you can use nearly the same answer for all your future versions that you will have to do on your own
- ANSWER =
- Put this in the
editor.rereplace
line in the script, remembering that I specifically said that if you have backslashes in the expression, you need to user'...'
instead of just'...'
:- ANSWER =
editor.rereplace(r'DamageCapacity="(\d*\.?\d+)"', add_1)
- ANSWER =
- Ask yourself, “what mathy replacement do I want to replace the match with?”
- ANSWER = “I want to multiply all the damage capacity values by 2”
- As per the FAQ, rename your sub if you aren’t actually going to be adding 1:
- a good name for multiplying by two would be
multiply_by_2
- You need to change every place in the script where it used to say
add_1
to now say the new name - CHANGE1: change
def add_1(m):
todef multiply_by_2(m):
- CHANGE2: change
editor.rereplace(r'DamageCapacity="(\d*\.?\d+)"', add_1)
toeditor.rereplace(r'DamageCapacity="(\d*\.?\d+)"', multiply_by_2)
- a good name for multiplying by two would be
- Ask yourself “what string do I want instead of
DamageCapacity="xxx"
?”- ANSWER = "I want
DamageCapacity="yyy"
where yyy is 2*xxx
- ANSWER = "I want
- Per the FAQ, you need to build that into the return expression.
- You currently have
return 'Y' + str(int(m.group(1)) * 2)
– this will return the letter Y followed by 2 times the value. This is obviously not what you want. - Change that
return
line to the following, so that it will beDamageCapacity="
followed by the number followed by"
– so it should be
return 'DamageCapacity="' + str(int(m.group(1)) * 2) + '"'
- You currently have
- Save your changes to the script.
- Read over your script. Make sure it makes sense for what you are trying to do
# encoding=utf-8 from Npp import editor def multiply_by_2(m): return 'DamageCapacity="' + str(int(m.group(1)) * 2) + '"' editor.rereplace(r'DamageCapacity="(\d*\.?\d+)"', multiply_by_2)
- Looks good to me
- Open the file you want to change the DamageCapacity on. Run this script on that file, then save that file.
- If there are more files where you want to double the DamageCapacity, do all of those.
Now, repeat that 11-step process for doubling the
Price="xxxx"
type lines (or, if you want to do 2.5, then use 2.5 in the appropriate location). Then repeat for theUnlockByRank
math. Then repeat for the division of Torque values by 1.05. Then repeat for …You have to customize the script each time to pick the right phrase from the file and to perform the right multiplication or division.
BTW: before you whine that doing those 11 steps separately for each individual parameter is a lot of work, remember: you would have to do a similar process in any text-editor-with-scripting you chose, not just Notepad++. You have asked for a complicated task. What you have really described is a brand new application which finds all the different attributes in a family of files, and applies the same scaling to each instance of that attribute across all the files – that’s a rather custom application, and writing a custom application to meet all your goals could take a professional software contractor a week or two to write it in a nice GUI would cost you an arm and a leg, and is not worth the prices since you’re just customizing game files of some sort. So the fact that you’ve been given this workaround for free, even though it requires thought and effort and repetition on your part, is still an awesome deal.
----
Addendum: this reply was done before Alan had highlighed that you also want to do this only within a certain range of selected text in the file. Wow, you are making this hard on everybody. Follow his instructions on that part. And remember, Notepad++ is a text editor; even Notepad++ together with PythonScript plugin isn’t a custom game-parameter-editing-suite, with all the builtin tools to make it simple to scale specific parameters in very narrow regions of a plethora of files. And good luck
- Ask yourself, “what am I searching for?”:
-
@john-russell said in Very new to notepad++:
Inbetween the <Winch and the </Winch> I highlight everything
I don’t want too or have too type stuff in there I want to literally just highlight the text I need and for it to work
First, by “highlight” you mean “select” the text.
Second, you can’t have it both ways, as there is only one possible selection when the script is run, you either have the text range you want to operate over selected OR you have a keyword (e.g.
Torque
) to operate on selected.press the relevant hotkey to either times the number by ‘X’ amount or to divided the number by ‘X’ amount
How is it supposed to know which (multiply / divide) you want?
I guess in this instance you get somewhat lucky because you can always multiply – and if you want divide you can just multiply by 1 over your number.And how is it supposed to know if you want to multiply by 2 or by 7 or whatever?
You seem to want a lot (which is OK), but you want it to happen almost automagically (which is OK to want, but…).
You probably need to invest some time in learning programming, then script programming specifically for Notepad++, if you want these types of solutions.
-
@peterjones said in Very new to notepad++:
You are expected to modify what the script searches for, and what the script replaces, so that it will give you the results necessary. We are not a free custom data manipulation outsource facility.
The example script shown in the FAQ is only an example, not a customized script for your specific situation. The intention is that users will modify the script in the FAQ to search for the text they want to match, and to output the text they want to replace it with.
For your level of skill, I would suggest doing things in multiple passes, one for each attribute that you want to change. I will show you an example of how to manipulate it for one – your
DamageCapacity="50"
and similar (ie, any that are attribute ofDamageCapacity
with an arbitrary number inside the quotes). The process that you need to go through:- Ask yourself, “what am I searching for?”:
- ANSWER = “I want
DamageCapacity
followed by equals sign, with a number in quotes”.
- ANSWER = “I want
- Ask yourself, “how do I translate that into a regular expression?”
- ANSWER =
DamageCapacity="(\d*\.?\d+)"
- Note: I used the floating point definition of a number, as derived from the other example I pointed you to earlier, so that way you can use nearly the same answer for all your future versions that you will have to do on your own
- ANSWER =
- Put this in the
editor.rereplace
line in the script, remembering that I specifically said that if you have backslashes in the expression, you need to user'...'
instead of just'...'
:- ANSWER =
editor.rereplace(r'DamageCapacity="(\d*\.?\d+)"', add_1)
- ANSWER =
- Ask yourself, “what mathy replacement do I want to replace the match with?”
- ANSWER = “I want to multiply all the damage capacity values by 2”
- As per the FAQ, rename your sub if you aren’t actually going to be adding 1:
- a good name for multiplying by two would be
multiply_by_2
- You need to change every place in the script where it used to say
add_1
to now say the new name - CHANGE1: change
def add_1(m):
todef multiply_by_2(m):
- CHANGE2: change
editor.rereplace(r'DamageCapacity="(\d*\.?\d+)"', add_1)
toeditor.rereplace(r'DamageCapacity="(\d*\.?\d+)"', multiply_by_2)
- a good name for multiplying by two would be
- Ask yourself “what string do I want instead of
DamageCapacity="xxx"
?”- ANSWER = "I want
DamageCapacity="yyy"
where yyy is 2*xxx
- ANSWER = "I want
- Per the FAQ, you need to build that into the return expression.
- You currently have
return 'Y' + str(int(m.group(1)) * 2)
– this will return the letter Y followed by 2 times the value. This is obviously not what you want. - Change that
return
line to the following, so that it will beDamageCapacity="
followed by the number followed by"
– so it should bereturn 'DamageCapacity="' + str(int(m.group(1)) * 2) + '"'
- You currently have
- Save your changes to the script.
- Read over your script. Make sure it makes sense for what you are trying to do
# encoding=utf-8 from Npp import editor def multiply_by_2(m): return 'DamageCapacity="' + str(int(m.group(1)) * 2) + '"' editor.rereplace(r'DamageCapacity="(\d*\.?\d+)"', multiply_by_2)
- Looks good to me
- Open the file you want to change the DamageCapacity on. Run this script on that file, then save that file.
- If there are more files where you want to double the DamageCapacity, do all of those.
Now, repeat that 11-step process for doubling the
Price="xxxx"
type lines (or, if you want to do 2.5, then use 2.5 in the appropriate location). Then repeat for theUnlockByRank
math. Then repeat for the division of Torque values by 1.05. Then repeat for …You have to customize the script each time to pick the right phrase from the file and to perform the right multiplication or division.
BTW: before you whine that doing those 11 steps separately for each individual parameter is a lot of work, remember: you would have to do a similar process in any text-editor-with-scripting you chose, not just Notepad++. You have asked for a complicated task. What you have really described is a brand new application which finds all the different attributes in a family of files, and applies the same scaling to each instance of that attribute across all the files – that’s a rather custom application, and writing a custom application to meet all your goals could take a professional software contractor a week or two to write it in a nice GUI would cost you an arm and a leg, and is not worth the prices since you’re just customizing game files of some sort. So the fact that you’ve been given this workaround for free, even though it requires thought and effort and repetition on your part, is still an awesome deal.
----
Addendum: this reply was done before Alan had highlighed that you also want to do this only within a certain range of selected text in the file. Wow, you are making this hard on everybody. Follow his instructions on that part. And remember, Notepad++ is a text editor; even Notepad++ together with PythonScript plugin isn’t a custom game-parameter-editing-suite, with all the builtin tools to make it simple to scale specific parameters in very narrow regions of a plethora of files. And good luck
I seen someone manually modding all these values for the game in choice (Snowrunner) on YouTube on Friday and decided to find the program he used which was Notepad++ and Cheat engine 7.2 i decided instantly cheat engine wasn’t what I was looking for so looked at downloading Notepad++.
But as everyone when they first start we are complete newbies. So when I see like"(\d*\.?\d+)"'
I’m like erm “English please” I don’t understand what this does.
But thanks for your help and I complete understand that you could charge for stuff like you can with anything that invest timeAnyway that made me think is there a way to do this easier than having to go through all files individually 9000+ with between 350 - 6800 letters in each of them and that’s when I remembered seeing him talk about Python and how it makes it easier in terms of memory hacking so I decided to ask here if it what i wanted to achieve was possible and got told about Python plugin
Thanks again I don’t mean to come across ungrateful or anything I just don’t have any idea of how to start. I appreciate your efforts and that goes for everyone that has replied
- Ask yourself, “what am I searching for?”:
-
@john-russell said in Very new to notepad++:
So when I see like “(\d*.?\d+)”’ I’m like erm “English please” I don’t understand what this does.
This is why I linked you to the regular expression documentation in my first reply in this thread.
Maybe now with ALL the background provided, there’s a good starting point for putting together a bit more of a demo – I’ll try to do this, and perhaps it will give you a better start.
-
Is what you want possible in Notepad++ & PythonScript plugin together? Yes
By @John-Russell? At this moment in time? No. After a day or two of asking us questions here? Not likely. After a few weeks or months of learning regular expressions (so that you understand
(\d*\.?\d+)
) and Python (so that you can figure out how to customize the simple example scripts to do something really complicated): maybe; I don’t know how quickly you learn.And honestly, what I think you’re trying to do would be faster with just writing a command-line program for Python – for which you would still have to learn Python, because this isn’t the forum for asking generic Python questions or for having us write you custom Python applications for free – or in some other language if you already know a programming language (I would personally write it in Perl if I were doing it for myself).
Since you’ve got 9000+ files that you want to edit, that’s not really the kind of thing that you want to invoke a text editor to do: text editors are made for editing one file at a time, or a few files at a time. If you’ve got a change that goes across hundreds or thousands of files, text editor isn’t the right choice. You could do it in PythonScript plugin in Notepad++, and the plugin would loop through the files, individually opening them, performing the changes, and then exiting – assuming that you don’t really need to highlight text in each file before doing the replacement.
But the situation I think you really have:
- You have a list of parameters you would like to change: DamageCapacity, Price, UnlockByRank, Torque, FuelConsumption, EngineResponsiveness, and so on.
- You have a mental list of scaling factors (2x, divide-by-1.05, 2.5x, etc) that you have a mental map of that scaling factor to the parameter
- You have a list of 9000+ files (hopefully all in the same directory or hierarchy, and hopefully all with a common file extension) that you want to perform the edits on
- You have unclear-to-me-requirements: on how many changes in each file:
- Maybe you want to scale every instance of DamageCapacity in every file it’s listed in by the same amount. If so, that’s actually relatively easy.
- Maybe there are multiple of each parameter in each file, but you only want to do the math in a certain section, and that section is the same in every file. For example, maybe only in <Winch> in every file, so you change any DamageCapacity and Torque and … in every <Winch>, but not in any other <PowerDrill> or <SuperTank> objects. If so, that’s a little more complicated, but still doable.
- If it’s any more complicated than that, you need to find an already purpose-built application to handle the complicated logic.
But we’ve given you a start in Notepad++ & PythonScript, and shown you how to do it on individual chunks to get started. If you want to make a more general-purpose solution, you are going to have to start putting in the effort to learn regular expressions and a programming language like Python. This Forum is not the place for learning either of those. (We help with quick regex in Notepad++, but we cannot handhold you through the entire process. And we will help with the Notepad+±related portions of PythonScript – how the PythonScript plugin interacts with the Notepad++ editor – but generic Python questsions don’t belong here.)
-
Ok so @Alan-Kilborn @PeterJones when I run the script for this
def multiply_by_2(m): return 'Torque="' + str(int(m.group(1)) * 2) + '"' editor.rereplace(r'Torque="(\d*\.?\d*.\d+)"', multiply_by_2)
and say the
Torque Value=70000
I press my hot key and everything is good value then turns toTorque Value=140000
I then come to the next segment in the file which for example isEngineResponsiveness=0.35
I press my hot key and nothing happens??Yesterday when I got help for
howManyblueitems=\d+
I found that it did the same it worked for everything unless the value had a decimal point. So with a bit of tinkering well basically - I just randomly added.\d+
so the code looked like thishowManyblueitems=\d+.\d+
and it worked and replaced the ones with decimals as well.So I’ve tried the same logic with
editor.rereplace(r'Torque="(\d*\.?\d+.\d+)"', multiply_by_2)
but it doesn’t work.How come?
-
Are you seriously expecting a search term containing
Torque=
to match something containingEngineResponsiveness=
?We are willing to go the extra mile in assisting, but we expect more thinking on the asking end.
-
@alan-kilborn said in Very new to notepad++:
Are you seriously expecting a search term containing
Torque=
to match something containingEngineResponsiveness=
?We are willing to go the extra mile in assisting, but we expect more thinking on the asking end.
No I had that changed just in my example I hadn’t
-
@john-russell said in Very new to notepad++:
No I had that changed just in my example I hadn’t
Well, we aren’t mind readers here. To get good help, you have to accurately convey what you’ve tried and what you still need assistance with.
-
@alan-kilborn said in Very new to notepad++:
@john-russell said in Very new to notepad++:
No I had that changed just in my example I hadn’t
Well, we aren’t mind readers here. To get good help, you have to accurately convey what you’ve tried and what you still need assistance with.
Yeah even when its changed to
editor.rereplace(r'EngineResponsiveness="(\d*\.?\d+.\d+)"', multiply_by_2)
it isn’t working (Just thought Id try just encase I made the same mistake :P) -
I just randomly added
.\d+
so the code looked like thishowManyblueitems=\d+.\d+
and it worked and replaced the ones with decimals as well.Your random experiments deceived you.
.
in a regular expression matches any character, so your howManyblueitems match would have matched the5.14
that is reasonable, but it would also have matched5x14
which would have then not worked for the muliply-by-2; you were just lucky you didn’t have any accidental matches.editor.rereplace(r'Torque="(\d*\.?\d+.\d+)"', multiply_by_2)
Why would you do such a thing?! I already told you that the expression I gave you,
\d*\.?\d+
matches a number with a decimal point in it. Specifically, it matches 0 or more digits, 0 or one decimal points, and 1 or more digits. That matches5
or.5555
or5.5555555555555
all equally well.If you think
r'EngineResponsiveness="(\d*\.?\d+)"'
doesn’t matchEngineResponsiveness="0.35"
, then you will need to show us data that proves this.But now I read and I see that your most recent example has
Torque Value=70000
(which has an extra word and no quotes) andEngineResponsiveness=0.35
(which has no quotes), so then my question would be “why do you think that a regex which requires quotes around a value would match a value that is missing the quotes?”. A regex that is looking forEngineResponsiveness="0.35"
can never match text that isEngineResponsiveness=0.35
, no matter how much you might wish it so.Also, there is 0 chance that the
Torque
script you showed would have matched yourTorque Value=70000
. Be explicit and accurate about your data and what you have tried, or we are unable to help you.----
Useful References
-
@peterjones said in Very new to notepad++:
If you think r’EngineResponsiveness=“(\d*.?\d+)”’ doesn’t match EngineResponsiveness=“0.35”, then you will need to show us data that proves this.
If you think r'EngineResponsiveness="(\d*\.?\d+)"' doesn’t match EngineResponsiveness="0.35", then you will need to show us data that proves this.
Unless I’m missing what you mean?? It doesn’t work for anything with a decimal! Unless decimals in Notepad++ mean something else?Here’s a link (Hopeful Vimeo don’t compress to much so its not watchable) to what I’m doing and you can see it doesn’t work. I’m probably doing something wrong but I don’t what that is.
link text -
@alan-kilborn said in Very new to notepad++:
there’s a good starting point for putting together a bit more of a demo – I’ll try to do this, and perhaps it will give you a better start.
I’m going to back down on this offer.
There is too much uncertainty and it seems lack of understanding on the part of the OP.
Sorry… -
@alan-kilborn said in Very new to notepad++:
@alan-kilborn said in Very new to notepad++:
there’s a good starting point for putting together a bit more of a demo – I’ll try to do this, and perhaps it will give you a better start.
I’m going to back down on this offer.
There is too much uncertainty and it seems lack of understanding on the part of the OP.
Sorry…Come on? I’m simply saying it didn’t work as intended and have shown you proof like you asked. I don’t like how you expect me to know this so quickly its whole new language its would take years in programming or something like that to know so quickly.
def calculate(match): return '%s' % (str(int(match.group(1)) * 10)) editor.rereplace('(\d+)', calculate)``` This works for all values including ones with decimals but then it doesn't have the feature of limiting it to a predefined term like```EngineResponsiveness="0.35"```
-
I found the problem.
The reason it was not changing was because
int("0.35")
was giving an error message in the PythonScript console that we were not seeing:Traceback (most recent call last): File "C:\usr\local\apps\npp\npp.8.4.2.portable.x64\plugins\Config\PythonScript\scripts\Multiply.py", line 7, in <module> editor.rereplace(r'EngineResponsiveness="(.*?)"', multiply_by_2) File "C:\usr\local\apps\npp\npp.8.4.2.portable.x64\plugins\Config\PythonScript\scripts\Multiply.py", line 5, in multiply_by_2 return 'EngineResponsiveness="' + str(int(m.group(1)) * 2) + '"' ValueError: invalid literal for int() with base 10: '0.35'
You did not read or understand in the example where it said,
To convert the text of a group to a number in python, use
int(m.group(1))
to make it an integer, orfloat(m.group(1))
to make it a floating point number.You were supposed to then understand that if you want Python to treat the string as a floating point number, you needed to use
float(m.group(1))
, notint(m.group(1))
.I should have remembered, as soon as you said “nothing happened”, to have you turn on Plugins > Python Script > Show Console to look for errors.
This works (proven):
# encoding=utf-8 from Npp import editor def multiply_by_2(m): return 'EngineResponsiveness="' + str(float(m.group(1))*2) + '"' editor.rereplace(r'EngineResponsiveness="(\d*\.?\d*.\d+)"', multiply_by_2)
I don’t like how you expect me to know this so quickly its whole new language its would take years in programming or something like that to know so quickly.
We don’t expect you to know all this immediately. What we expect is that you understand that this is a complicated task – not the simple search and replace you assumed – and that it’s really not a problem that should be solved in Notepad++ or any other text editor, but rather in a programming language, and that you should understand we’ve already explained that this forum is not a general “write code for me” forum, or even “help me write my code”. This is about Notepad++, but your discussion has been about a very specific set of data manipulation requirements which we’ve explained multiple times cannot be handled by search-and-replace alone. But you keep on posting as if you expect us to do all this for you. So we keep trying to help you, despite the fact that it’s moved way off topic from a text editor question.
But if we are going to continue to help you – volunteering our time to help you do something that’s only microscopically related to the topic of this forum – then you are going to have to put in the effort. Things like saying
Torque Value=70000
when you meanTorque="70000"
or sayingEngineResponsiveness=0.35
when you meanEngineResponsiveness="0.35"
are not helping your cause, and are not putting in the effort. Saying “it didn’t work” or “nothing happened” are not putting in the effort.If you are going to try random things – which is allowed – you are going to have to show us exactly what you tried when it didn’t work, not some approximation that doesn’t actually match reality.
If you had said
I have the following exact text:
<EngineVariants> <Engine DamageCapacity="120" EngineResponsiveness="0.35" > ... </Engine> </EngineVariants>
and I ran the exact script
# encoding=utf-8 from Npp import editor def multiply_by_2(m): return 'EngineResponsiveness="' + str(int(m.group(1))*2) + '"' editor.rereplace(r'EngineResponsiveness="(\d*\.?\d*.\d+)"', multiply_by_2)
but it did nothing. I think it is not matching the decimal point correctly, so I tried
editor.rereplace(r'EngineResponsiveness="(\d*\.?\d+.\d+)"', multiply_by_2)
instead, but that still didn’t workIf you had said that, we would have had the exact representation of what you had tried, and we could have copy/pasted it into our own Notepad++, and we could have seen that nothing happened for us either.
Instead, you gave text that didn’t match your actual data, and then after much prompting showed a video which we had to click somewhere else to see, that showed you using a regex that we hadn’t suggested (so it was proving your regex bad, if anything, not that the one I supplied was bad). It took me 15 minutes just to watch the video enough and type up some example text and try to recreate the exact circumstances enough to replicate your problem. And then that long again to type things up in a way that I hope you will understand and take to heart.
-
@peterjones said in Very new to notepad++:
I found the problem.
The reason it was not changing was because
int("0.35")
was giving an error message in the PythonScript console that we were not seeing:Traceback (most recent call last): File "C:\usr\local\apps\npp\npp.8.4.2.portable.x64\plugins\Config\PythonScript\scripts\Multiply.py", line 7, in <module> editor.rereplace(r'EngineResponsiveness="(.*?)"', multiply_by_2) File "C:\usr\local\apps\npp\npp.8.4.2.portable.x64\plugins\Config\PythonScript\scripts\Multiply.py", line 5, in multiply_by_2 return 'EngineResponsiveness="' + str(int(m.group(1)) * 2) + '"' ValueError: invalid literal for int() with base 10: '0.35'
You did not read or understand in the example where it said,
To convert the text of a group to a number in python, use
int(m.group(1))
to make it an integer, orfloat(m.group(1))
to make it a floating point number.You were supposed to then understand that if you want Python to treat the string as a floating point number, you needed to use
float(m.group(1))
, notint(m.group(1))
.I should have remembered, as soon as you said “nothing happened”, to have you turn on Plugins > Python Script > Show Console to look for errors.
This works (proven):
# encoding=utf-8 from Npp import editor def multiply_by_2(m): return 'EngineResponsiveness="' + str(float(m.group(1))*2) + '"' editor.rereplace(r'EngineResponsiveness="(\d*\.?\d*.\d+)"', multiply_by_2)
I don’t like how you expect me to know this so quickly its whole new language its would take years in programming or something like that to know so quickly.
We don’t expect you to know all this immediately. What we expect is that you understand that this is a complicated task – not the simple search and replace you assumed – and that it’s really not a problem that should be solved in Notepad++ or any other text editor, but rather in a programming language, and that you should understand we’ve already explained that this forum is not a general “write code for me” forum, or even “help me write my code”. This is about Notepad++, but your discussion has been about a very specific set of data manipulation requirements which we’ve explained multiple times cannot be handled by search-and-replace alone. But you keep on posting as if you expect us to do all this for you. So we keep trying to help you, despite the fact that it’s moved way off topic from a text editor question.
But if we are going to continue to help you – volunteering our time to help you do something that’s only microscopically related to the topic of this forum – then you are going to have to put in the effort. Things like saying
Torque Value=70000
when you meanTorque="70000"
or sayingEngineResponsiveness=0.35
when you meanEngineResponsiveness="0.35"
are not helping your cause, and are not putting in the effort. Saying “it didn’t work” or “nothing happened” are not putting in the effort.If you are going to try random things – which is allowed – you are going to have to show us exactly what you tried when it didn’t work, not some approximation that doesn’t actually match reality.
If you had said
I have the following exact text:
<EngineVariants> <Engine DamageCapacity="120" EngineResponsiveness="0.35" > ... </Engine> </EngineVariants>
and I ran the exact script
# encoding=utf-8 from Npp import editor def multiply_by_2(m): return 'EngineResponsiveness="' + str(int(m.group(1))*2) + '"' editor.rereplace(r'EngineResponsiveness="(\d*\.?\d*.\d+)"', multiply_by_2)
but it did nothing. I think it is not matching the decimal point correctly, so I tried
editor.rereplace(r'EngineResponsiveness="(\d*\.?\d+.\d+)"', multiply_by_2)
instead, but that still didn’t workIf you had said that, we would have had the exact representation of what you had tried, and we could have copy/pasted it into our own Notepad++, and we could have seen that nothing happened for us either.
Instead, you gave text that didn’t match your actual data, and then after much prompting showed a video which we had to click somewhere else to see, that showed you using a regex that we hadn’t suggested (so it was proving your regex bad, if anything, not that the one I supplied was bad). It took me 15 minutes just to watch the video enough and type up some example text and try to recreate the exact circumstances enough to replicate your problem. And then that long again to type things up in a way that I hope you will understand and take to heart.
that this forum is not a general "write code for me"
Sadly some people learn this way and I’m one of those people. I don’t do well with text books I’m more hands on kind of guy (Practical Learning).Just some of the language you were typing was coming off a little aggressive which I’m sure you didn’t mean to be. Heres an example
Are you seriously expecting a search term containing Torque= to match something containing EngineResponsiveness= ?
I just took slight offense to it. I’m human we make mistakes but I understand that you wouldn’t of know that it was a mistake
It would of just come off a bit more friendly if you had said
Your mistake is "Your search term need to match 'EngineResponsiveness=' and not read 'Torque+'.
Then I could of just replied
oh yeah silly me I typed it wrong in the example shown but I wrote it correctly in the script and is still not working
Anyway thanks for handling this maturely unlike most people on the internet. Good Job and I will take a look at the code you have sent in a little bit :)
-
This post is deleted! -
This post is deleted! -
Above code works perfectly 😁 Thank You 👍