Case convertion: Match `A` unless followed by a `-` `Major` or `Minor`

I have been using this regular expression for case conversion with hardly any negative effects.

Regular Expression: (?<!&|:|;|-|/|!|,|>|/|(?<![A-Z]\.[A-Z])\.|\)|\?|\+)(\s+\b(A|An|And|As|At|But|By|De|Et|For|From|In|Into|Le|Nor|Of|Off|On|Onto|Or|So|Than|The|To|Upon|Von|With)(?=\s)(?!\s[\-\(\)\[\]{}]))

Replace with $lower($1)

One that does exist is that it will turn classical title that have A Major or A-flat Minor in them, for example, will be converted to a Major of a-flat Minor

So I am wondering how I can modify this regular expression so the A will not be matched if followed by a dash (-) or by the words major or minor whether they are capitalized or not. I tried to brush up on my regex skills to give it a tackle but after a bit of reading I have no clue. I would be at this for hours and hopefully it is easy for someone more versed than I in regular expressions.

Sorry, way above my paygrade but try this site to examine your regex:

I would not modify a complex but working regular expression but apply another action that sets the correct case for the exceptions - and that with a simple "replace" where you replace text constants with other text constants.

With this complexity:


I suggest to search a solution as mentionend from @ohrenkino too.

OK. I thought it would be simpler, but it seems to be too complex even for the experts here, so maybe I should not feel so bad about my skills. I will try ohrenkino's suggestion.

ohenkino, are you suggesting nesting the action in the original action where I create a replace value in the Title, ala,
replace a major with 'A Major'
replace a Major with 'A Major'
replace a minor with 'A Minor'
replace a Minor with 'A Minor'
replace a- with 'A-'

If you are fond of more complex scripting expression, you may as well nest the original regular expression in a $replace() call.
You may also use an action of the type "Guess value" in which you $replace() all the fields in which you expect the strings to appear and then separate them again.
Or you use an action group in which you add an action of the type "Replace" for "a minor" and "a Major" and set it to be case sensitive.
Or you add an action of the type "Format value" for the field and use $replace() in the format string.

That would replace the Norwegian synth-pop band
a-ha
to
A-ha

or change a song title as
Sing-a-Long
to
Sing-A-Long

You can use two more regular expressions to replace all case spellings of a major
$regexp(%TITLE%,a MaJoR,A Major,1)
$regexp(%TITLE%,a mINOr,A Minor,1)
just write a ,1 at the end of the $regexp command and this will enable "ignore case" and find all variants as

a MaJoR
a major
A MAJOR
A MAjoR

and so on

If you are looking for a solution for all variants from A minor through G-Major, you could test this one:

Action: Replace with regular expression
Field: Whatever tag you want to modify, in this example it is the TITLE tag
Regular expression: (1)
([a-g])[\s-](m(aj|in)or)
Replace matches with: (2)
$upper($1)-M$lower($3)or


Explanation for (1)
image


Explanation for (2)
Write content of $1 in UPPERCASE (<- The letter A through G)
followed by a hyphen and the letter M
Write content of $3 in lowercase (<- either aj or in)
followed by the letters o and r

If you don't like the hyphen in the end result, just let it out in the replacement string
$upper($1) M$lower($3)or

Interesting solutions, though I may not understand them all jet. I am not sure why MaJoR or mINOr was written that way. Good point about a-ha and Sing-a-long. I guess I could just use a-f and a-s for the sharp and flats.

Another thing I am considering is just running the action where I create Titles from Work, Movement, Movement Number after the case conversion clean up action. I have set up a protocol of what to do with files to ensure they are tagged correctly before importing them. Creating Tiles from those fields is a step for classical music. since I do not run the case conversion cleanup action of the Work field, it will remain with the correct case and correct erroneous titles created by the case correction action when run.

The only caveat is that I do this for only classical and this situation may come up in a non-classical title. So perhaps adding the action on the Title filed:
replace a major with 'A Major'
replace a Major with 'A Major'
replace a minor with 'A Minor'
replace a Minor with 'A Minor'
replace a-f with 'A-f'
replace a-s with 'A-s'
I rather keep things case sensitive.

This problem only occurs with the key of a, as far as I can tell, so I will just work with this closed set.

To tidy up this thread, I realized I did not have to create the a-f and a-s as the A sharp and flat titles were not changed by the original reg ex expression. I thought they had but I was mistaken. It only converts the A to lower case if it stands alone. So that step was not needed.

I also found it better to not make the replace case sensitive in case there somehow was an minor or major that somehow escaped my case correction action. Even though that may not be possible, I don't see how it could hurt to not make the Replace action not case sensitive.

We don't know your music source(s). We don't know all your Actions an regular expressions that you apply to what songs.

It's really up to you IF and WHAT kind of replace Action do you use for what subset of music files.

My very personal preference is:
Everything that could be a possible spelling mutation should be detected and then adjusted.