in reply to Re: Re (tilly) 3: parsing question
in thread Re: parsing question

You just changed the problem massively. I didn't promise that the RE engine magically has become able to handle arbitrary parsing problems. I never said that no variables were involved. I merely said that the RE engine can handle balanced delimiters.

The two experimental features which are needed are (??{}) for delayed evaluation and (?>) for telling the engine not to backtrack. A sample script demonstrating the technique:

#! /usr/bin/perl my $braces; $braces = qr/(\((?:(?>[^\(\)]+)|(??{$braces}))*\))/; while (<>) { if ($_ =~ $braces) { print "Matched '$1'\n\n"; } else { print "No match\n\n"; } }
Run it and start typing in lines. The ones with balanced parentheses will match.