How to make Grammartron ignore text within [brackets] ?

With a little tweaking I've been able to adapt Grammartron to suit my needs pretty well, except that many of my files have descriptive elements within brackets that I don't want capitalized, such as "Song Title [alt take 1]". I can write a script to lowercase a string within brackets, but if I happen to re-run Grammartron afterwards it will capitalize those strings and I'll have to lowercase them all over again, so I'd like to modify Grammartron to ignore text within brackets. Unfortunately, my regex skills are not up to snuff. Can anyone help me out?

Could you tell us which expression from within Grammartron capitalizes after the square brackets?

The alternative would be to add an action to the Grammartron (?!) the de-capitalizes the expression in square brackets. Would probably be easier to write and maintain as it does not mess with the original action.

This seems to be the main action:

[#17]
T=4
! Title Case Conversion [1] (Convert Words to Mixed-Case, Ignoring Upper-Case Letters)=
F=_TAG
1=([-({\\[\\]}) _",./+&@:;*])(\\l)
2=$1$upper($2)
3=1

Yes, I could do that, but it wouldn't be ideal because there might be instances when I would not want everything within the brackets lower-case. For example: "Song Title [US version]".

Now you have lost: as MP3tag cannot read and does not speak English, it cannot tell if the case is OK or not.
You would have to device a list of exceptions to the rule. Like US.

As for the action:
I think
1=([-({\\[\\]}) _",./+&@:;*])(\\l)

should become

1=([-({\]}) _",./+&@:;*])(\\l)

Thanks for your help, that seems to work. I gave it a quick test, but I'll test it more thoroughly later. Can you help me with another problem that popped up? I wrote this action to lowercase any text within parentheses and replace the parentheses with brackets:

[#0]
T=4
! Replace (Text String) with [Text String]=
F=TITLE
1=\\((.+)\\)
2=[$lower($1)]
3=1

It usually works, except when the text string includes a comma. For example, "Air Mail Special (Stratford, Ontario Jazz Festival)" becomes "Air Mail Special [stratford]".

If I apply that action (Replace with regular expression) then the string "Air Mail Special (Stratford, Ontario Jazz Festival)" stays absolutely the same. Nothing left out, no case conversion, no replacement.

Then you're doing something wrong.

I only get the same result as you if I use
((.+))
instead of
\\((.+)\\)

Actually, I am not sure if the "lower" and "upper" functions still work properly.
If you use them in the tag-tag-converter as $regexp() then the preview does not show any changes to the orginal string....
So I am not sure if the $upper() etc. functions actually use the comma as string separator.

If you copy/paste \\((.+)\\) into Actions or Actions (Quick) mp3Tag will add additional backslashes, which is probably why it wasn't matching anything. If you copy/paste my code directly into a .mta file in the actions folder, then run the action, it should work as I've described.

I don't understand why it would be looking for string separators when it is only supposed to be working on a title tag. Can you think of an alternate method to lowercase text within brackets?

I tried
$regexp(%title%,((.*)),'\L[$1]')
and that works

Thanks, but I'm only familiar with using the Actions format and I don't know how/where to use this script. The Help pages are not very helpful in that regard. Does this script work in an Actions .mta file?

You can enter the $regexp() as the format string in a "Format value" action.
Or you separate the 3 parts of the expression as the items for a "Replace with regular expression" action.

Vielen Dank. I got that to work as a "Format value" action. However, when I modified it to lowercase text within brackets instead of parentheses, like so,

$regexp(%title%,[(.*)],'\L[$1]')

... I get an error:

REGEXP ERROR: Regular expression
Incomplete escape sequence found. The error occurred while parsing the regular expression: '>>>HERE>>>'.

Try it with more apostrophes:
$regexp(%title%,'[(.*)]','\L[$1]')

Thanks again.