in reply to Maximal match in a recursive regex

Just a quick note that I consider using [^][]+ in a regex to be obfuscation. (: I realize that backwhacks are a bit ugly, but I don't condone relying on the little-used trick that ] is not special when it is the first character (including after the optional "^") of a character class.

I'd prefer [^\[\]]+, even though the eye doesn't have the easiest time lining up the brackets (it is ugly while your construct is pretty but misleading, like an optical illusion). :)

                - tye

Replies are listed 'Best First'.
Re: Re: Maximal match in a recursive regex ([^][]+)
by diotalevi (Canon) on Jun 26, 2003 at 18:29 UTC

    Huh. And I wasn't even attempting to mentally match the internal brackets with the external ones. I just wrote it correctly so I wouldn't need backwhacks and that it coincidentally looks like two classes entirely escaped me. Thanks for altering me to that mental blindspot.