Replace random values with 0
-
Hello. I want to search for this (in Notepad++)
env_factor : { x , y , z }
Where x,y,z are random values/numbers And replace with this
env_factor : { 0 , 0 , 0 }
An example
env_factor : { 0.5215321 , 0.11243 , 0.94 } to replace with
env_factor : { 0 , 0 , 0 }Thank you.
-
From the main menu, select Search | Replace… and fill in:
Find what:
env_factor\s*:\s*\{\s*\d+(\.\d*)?\s*,\s*\d+(\.\d*)?\s*,\s*\d+(\.\d*)?\s*\}
Replace with:
env_factor : { 0 , 0 , 0 }
Be sure the radio button Regular expression is selected and use the Replace All button.
This does not take into account numbers that might have minus signs or that might begin with a decimal point, without the leading zero. If you have numbers like that, replace the parts in the search like this:
\d+(\.\d*)?
with:
-?(\d+(\.\d*)?|\.\d+)
to get:
env_factor\s*:\s*\{\s*-?(\d+(\.\d*)?|\.\d+)\s*,\s*-?(\d+(\.\d*)?|\.\d+)\s*,\s*-?(\d+(\.\d*)?|\.\d+)\s*\}
-
@ Coises You are amazing,thank you very much.