in reply to Re: knapsack problem solved by regex
in thread knapsack problem solved by regex
It has to do with the string being anchored at the central '0'.
Thus, thanks to this anchoring at the '0' character, the regex engine does indeed backtrack through combinations of v's in descending order of their sum.Exactly. That "middle anchoring" is one of the main tricks in this regex. I also had to go through your previous to last regex example to find the last while crafting this. :-)
|
|---|