From: tho_mica_l Date: 2008-02-08T18:19:56+09:00 Subject: Re: regex dynamic count modifier {min, max} ? > To parse a logic statement like this: > > fn:function3(fn:function2(fn:function1(xargs))) Are you looking for something like this (ruby19): def get_fns(string, count=0) m = /(? fn:[\w\-]+ \s*\(\s* (\g|[^)]*) \s*\) )\s*/xi.match(string) if m n = /^(fn:[\w\-]+)(\s*)\((.*?)\)$/.match(m['fn']) puts "FN #{count}: #{n[1]} with args #{n[3]}" get_fns(n[3], count + 1) end end a = "foo fn:function3(fn:function2(fn:function1(xargs))) foo(bar) bar" get_fns(a) > a = "foo fn:function3(fn:function2(fn:function1(xargs))) foo(bar) bar" > get_fns(a) FN 0: fn:function3 with args fn:function2(fn:function1(xargs)) FN 1: fn:function2 with args fn:function1(xargs) FN 2: fn:function1 with args xargs => nil Regards, Thomas.