Sounds like you need a proper parser. This is similar to why you need more than just regexen to parse (arbitrary) HTML reliably.
And just a thought, you might find it easier to implement in with grep rather than a regex.
--
We're looking for people in ATL
In reply to Re: Yet another regex question
by Fletch
in thread Yet another regex question
by gregor-e
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |