>>>>> snip >>>>>
> Onigurama does not recognize left recursion correctly.
Why should it?  (See below.)
>>>>> snap >>>>>

Because it is described in the Onigurama documentation

>>>>> snip >>>>>
> As I wrote in my earlier message
>
> -----------------------------------------------------------
> orgstring= "5-((3+4)*5)+6+xx"
> pattern = /^(?<bal>[^()]*(\(\g<bal>\)[^()]*)*)$/

You make my eyes bleed...  Please don't use regular expressions for
matching parentheses, it simply can't be done using regular expressions
(well, .NET-"regular expressions" can, and perhaps there's some support
for it in Oniguruma as well, but definitely not in the way you're doing
it.).
>>>>> snap >>>>>

It is normal usage like the bal-Pattern in Snobol4. I agree that this is not good for fixed programms, but my
usage of Ruby is mainly interactive data analysis (now done using IRB, later using a special shell). It is
very helpful in this case,


>>>>> snip >>>>>
> -----------------------------------------------------------
> never ending recursion: /^(?<bal>[^()]*(\(\g<bal>\)[^()]*)*)$/
> -----------------------------------------------------------
>
> which is definitely wrong.

No, it's definitely right.  Your trying to match a <bal> inside a <bal>,
right?  That sounds like infinite recursion to me,
>>>>>  snap >>>>>

Sorry, strong disagreement. The part "(\(\g<bal>\)[^()]*)*" will either recognize nothing or it must consume a
"("-Character before coming to the recursive "\b<bal>"-Part.

Best regards, Wolfgang Nadasi-Donner