What you need is a dot that doesn't match any of your other items of interest. Perhaps (untested):
$middle = "(?:(?!$left|$right|$escape$left|$escape$right).)";
-- Randal L. Schwartz, Perl hacker
In reply to Re: Determining if you have balanced delimiters
by merlyn
in thread Determining if you have balanced delimiters
by Ovid
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |