in reply to finding { and }
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?
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: finding { and }
by Aristotle (Chancellor) on Oct 17, 2001 at 07:14 UTC |