On Wed, 23 Jan 2008, Thomas A. Schmitz wrote:
On Jan 23, 2008, at 10:50 PM, Peter Münster wrote:
I've just seen, that it does not work for nested braces: \footnote{x{y}z}: ok \footnote{x{y{z}}}: not ok
The next one (normal regexp, not extended) has support for up to one level of nesting:
\\footnote{[^{}]*\([^{}]*{[^{}]*\([^{}]*{[^{}]*}[^{}]*\)*[^{}]*} [^{}]*\)*[^{}]*}
Wow. This shows regexes are easier to write than read. I would have never managed to read what this does (and I know regexes fairly well).
These examples seem to work: \footnote{x{y}z} \footnote{x{y{z}}} \footnote{x{y}z} \footnote{x{y{z}}x{y{z}}x{y}z} \footnote{x{y{z}}x{y{z}y{z}y}x{y}z}
Cheers, Peter
You could also use a nice scripting language like ... lua!! lua has support for "balanced strings," so no nesting trickery is needed, see http://www.lua.org/pil/20.2.html (scroll to the bottom of the page). Or you could try and nag Hans into giving a nice tutorial on the lua lpeg library at Bohinj! :-)
Another option is Gema http://gema.sourceforge.net/new/index.shtml (also has a lua library gel http://gema.sourceforge.net/new/gel.shtml). You can define regions and matching nested braces quite easily. Aditya