in reply to Re: Is there any other way to avoid greedy matching
in thread Is there any other way to avoid greedy matching

Your update is completely wrong. '123' =~ /(.*)(\d)/ will match just fine. If .* matches too many characters for \d to match, backtracking will occur causing .* to match fewer characters.

'123' =~ /(.*)(\d)/ (12)(3) '123' =~ /(.*?)(\d)/ ()(1) 'a123z' =~ /(.*)(\d)/ (a12)(3) 'a123z' =~ /(.*?)(\d)/ (a)(1)