Solution #2.
/hsave -i <stuff> testing_hash
alias del_line {
var %i = 0 , %file = testing.ini , %section = testing_hash
while ($read(%file, r, /^[^=]+=.*delete.*/, %i)) {
var %v1 = $v1
if ($regex(%v1,/^([^=]+)=.+/)) { var %here = $regml(1) }
remini %file %section %here
var %i = $calc($readn + 1)
}
}
That's about as quick as it's going to get without looping through the entire file. You can modify the alias, and change the regex part of the $read() to whatever you need it.
I tested this using:
/hadd -m testing one keep this one
/hadd -m testing two should delete this
/hadd -m testing three we'll keep this one, it's neat.
/hadd -m testing four this one isn't as cool as three, let's delete it.
/hsave -i testing.ini testing_hash
/hdel -w testing *
/del_line
/hload -i testing testing.ini testing_hash
Just in case some of you would like to play around with it.
Edit: On second thought, the code can be simplified to:
alias del_line {
var %i = 0 , %file = testing.ini , %section = testing_hash
while ($read(%file, r, /^([^=]+)=.*delete.*)/, %i)) {
remini %file %section $regml(1)
var %i = $calc($readn + 1)
}
}