in reply to Re: The greedy change-making problem using regexes
in thread The greedy change-making problem using regexes
I suppose I could also use (?>pattern) to prevent backtracking and perform the greedy match without the negative lookaheads?
Although I can't say I've ever really used (?>pattern)...(1 x $money) =~ /^(?>(1{10})*)(?>(1{6})*)(?>(1{5})*)(?>(1{1})*)$/
Anyway, the pain in the butt is counting the number of coins. I like my little (?{$^R+1}) idiom!
blokhead
|
---|