How can I write a (La)TeX command that replaces all [ with { and all ] with }, assuming that every [ has a matching ], and that any braces between the [ and ] are balanced? It needs to be able to deal with nested brackets.
For example, I want to be able to write a command \mynewcommand
so that \mynewcommand{{[[{1}{2}][{3}{4}]]}}
is the same as \mycommand{{{{{1}{2}}{{3}{4}}}}}
.