Thread:LunaBot/@comment-3474542-20130724232809/@comment-3474542-20130725233734

LunaC wrote: I did not fully get what the replacing should be

I understand the result code, I understand the finding. But how should I make a replace with keeping or even making it double. If I search for FIND = string1 "(harvestcoin) = (\d+)/)"  replace with  | harvestcoin = (\d+)/) | harvest_curr_type1 = coin |harvest_curr_amt1 = (\d+)/) it will find the digit but probably remove it instead of adding it again. I don't think it will just paste the number it found...

The parentheses "( )" signs are called capture groups. That means that whatever they find can be used with a backreference (the code $1, $2, $3, etc). Just like with templates and unnamed parameters, the groups that are captured are numbered in order of appearance. The $1 means "input results matching the search terms in the first " and the $2 means "input results from the second ". So... from your code, it should probably be:

IF \|\s*?harvest(cash|coconut|coin|jade|other)\s*?=\s*?\(\d+)/) FIND \|\s*?harvest(cash|coconut|coin|jade|other)\s*?=\s*?(\d+)/) REPLACE


 * harvest_curr_type1 = $1
 * harvest_curr_amt1 = $2
 * harvest($1) = $2

That would be translated into human as:

IF the non-blank parameter | harvestcash, OR | harvestcoconut, OR | harvestcoin, OR | harvestjade, OR | harvestother exists, THEN

FIND the parameter | harvest(capture group of various words for type) = (capture group for any number)

and REPLACE it with


 * harvest_curr_type1 = backreference #1


 * harvest_curr_amt1 = backreference#2


 * harvestbackreference#1 = backreference#2