Reputation: 1
I have entries in a code that look like this
hit_power=0.57
These entries have different variables like 0.4, 0.65, 0.55 and so on, and there is dozen of them in every file. I want to replace all hit_power= entries with hit_power=0.5, but when i try to find hit_power= and replace it with hit_power=0.5 it will replace it but the former argument of function will stay, so for example i replace hit_power=0.65 to hit_power=0.5, and in th result i will get hit_power=0.50.65. How do i remove an entry with hit_power= function and replace it with new function and an argument?
Upvotes: 0
Views: 61
Reputation: 1
It seems there's a tabulator[or few spaces] after hit_power= equation. So it can't find the phrase. So is there any way to find a line with
hit_power=
erase the line which the phrase occupy with all marks and arguments after it, and then replace with a new line, with new phrase? It would be like this:
Find all lines with
hit_power
Remove line[s] with hit_power and all spaces,tabs, marks, arguments after it, completely, for example:
hit_power= 0.57
hit_power= 0.43
hit_power= 0.52
and replace with
hit_power=0.5
hit_power=0.5
hit_power=0.5
The formula that was provided by some answers in this topic, were enough to find hit_power=x and replace it with hit_power=0.5. But it can't find phrase when there are spaces/tabs after = mark.
Here;s the actual code: http://pastebin.com/eLagUcCB
Ok found the answer, just need to use formula
Find
hit_power.*
Replace with
hit_power=0.5
Thanks for answers nevertheless!
Upvotes: 0
Reputation: 91508
Use this:
Find what: (?<=hit_power=)\d\.\d+
Replace with: 0.5
(?<=hit_power=)
is a positive lookbehind, that makes sure there is hit_power=
before the digits, but it's a zero length assertion and doesn't capture it.
Upvotes: 0
Reputation: 1916
In the replace window use this text in Find hit_power=[0-9].[0-9]*
and set the Search Mode to Regular expression.
Upvotes: 1