Your problem's been addressed. But... rather than split-ing the string, and examining individual characters, why not use index? That removes the problem with regexps and brackets, as well as being faster.
If $brackets ever goes below 0, you've got a problem, even if the final total is ok: consider )(. And you're not considering brackets inside strings:printf("(");
Of course, the logical extension is to consider the number of round brackets inside each pair of curly brackets. At this rate you're going to end up with a full blown syntax checker. Why not hand the whole thing over to the compiler?
In reply to Re: finding { and }
by tommyw
in thread finding { and }
by dudi
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |