Find and Replace help
-
Hello. I want to modify values in multiple files but problem is values differ from one file to another.
Example:test=“6.5” must be replaced by test=“1.0”, but in every file there are different values.
question: How to find test=“1.0 to 100.0” with step 0.1 and replace them all by test=“1.0”?
Thank you in advance
-
It depends on how restrictive you want to be. And how literal your limit of 100.0 was meant to be.
Do you want
test="100.0"
to change or not? What abouttest="100.1"
? Do you want to changetest="66.0"
, but nottest="66"
(so requiring the decimal point, even when it is zero)? There are all sorts of test cases that significantly change the regex.With the assumptions that the decimal and tenths digits are required, and that 100.0 is a hard limit and inclusive: FIND =
test="1?\d{1,2}\.\d"
, MODE = Regular Expression. Any other assumptions would require changing the regex.–
addenda: even that assumption shows I forgot to test for edge cases while thinking about edge cases; your original spec says1.0 to 100.0
, but mine allows0.0 to 100.0
, and I don’t feel like figuring out how to make it more restrictive until we know what your actual edge case needs are. -
Thank you for your suggestion. I don’t think value goes to 100.0. mostly it will be under 9.9. Don’t know if I got you right, but seems it isn’t working. Anyways thanks for help.
*edit.
Thank you it is working flawlesly.
-
@Levan-Davitadze said in Find and Replace help:
Don’t know if I got you right, but seems it isn’t working
Your screenshot shows “Normal” mode, you need “Regular expression” mode.
*edit. Thank you it is working flawlesly.
I included this note even after I saw the edit, so that future readers will know what was wrong.
-
@PeterJones Hello friend.
I need another help if you have time please.
Can you suggest how to reduce and replace with reduced value existing one, instead of writing exact number? f.e. "BodyFrictionAsphalt=“found value/2” or percent of found value, f.e. …=found value 34%
Thank you very much in advance.
-
@Levan-Davitadze said in Find and Replace help:
Can you suggest how to reduce and replace with reduced value existing one, instead of writing exact number? f.e. "BodyFrictionAsphalt=“found value/2” or percent of found value, f.e. …=found value 34%
You are talking about doing a mathematical replacement.
There is no native support in Notepad++ for that.
If you want to do it with Notepad++, you have to do scripting.
More information is HERE. -
@Alan-Kilborn Thank you.