Replace value according to previous line
Im editing sfz (a music samples standard), and would need to edit that kind of thing :
*<region> sample=Samples\Blister Pack5\Baghhopen.wav
<region> sample=Samples\Blister Pack5\Bagsnes1.wav
<region> sample=Samples\Blister Pack5\Bagsnes2.wav
etc etc (hundreds of values)
What i need to do is knda simple i guess, i need the xx value for “pitch_keycenter=” to be set according to what previous line say (hikey=yy)
In this case i would need to respectively set the “pitch_center” values, to 0,1 and 2.
Is there a way to achieve this in np++ ?
Thanks a million
Well, it’s easy enough to achieve that S/R !
Go back to the very beginning of your file
Open the Replace dialog and choose the
Regular Expressionsearch mode
In the SEARCH zone, type
In the REPLACE zone type
Click on the Replace All button
\d+represents any number (one or more consecutive digits )
\Ris any End of Line (
\r\nfor a Windows file,
\nfor an Unix file or
\rfor an old Mac file
(\d+)\Rpitch_keycenter=stands for the group 1, which is re-written, first, (\1), in replacement
The first regex
\d+is the group 2 ( the number at the end of the hikey line, before the EOL and pitch_keycenter ), which is re-written, last, (\2), in replacement
You can either use that other regex syntax :
The regex engine tries to match the regex
\d+is the group 1 ( the number at the end of the hikey line
Then, due to the
\Kform, the regex engine forget the previous match and tries, now, to match the remaining. That is to say, the simple regex
\d+( the number, at end of the pitch_keycenter line )
This number is, finally, replaced by the value of group 1
DON’T use the step-by-step Replace button, with that second syntax
Hope these regexes will be useful to you !
Wow, thank you very very much, guy038, you not only almost saved my life :), but you took the time to explain things extensively to me, thanks again !