Capitalizing names with Mc/Mac


#1

I was sure there was once topic about this already and I searched the forum, couldn't find it...

So now I'm asking here. I got this action from this forum for renaming names from, for example, Mcdonalds to proper McDonalds. Action is this:

Replace with regular expression

Regular expression
\bMc(?=.)

Replace with
Mc$upper($1)

But i was trying this action today and it's not working, tried to fix it by myself and gave up.

So what is wrong with it?


Names With Apostrophes
#2

Use this expression \bMc(\l)


#3

Ah, it works! Thank you!


#4

Could you please explain how that works?

I've removed \b since some artists begin with Mc, in which case that wouldn't work, so:

Mc(\l)

and replace with

Mc$upper($1)

Since \l is in brackets, it is grouped and you can acces it by calling $1. Very well. What if I want to capitalise every letter after Mc? Or two? Does \l mean one character only? Putting dot inside brackets instead of \l makes no difference.


#5

I believe MP3Tag uses the "Boost.Regex" library, which supports both the basic and extended standardized syntax as defined by POSIX

Although many in the forum here are very generous with their time wrt regex tutoring, that is a huge topic area of which self-teaching references abound all over the intertubes, and also note really an MP3Tag-specific issue.

You can find a comprehensive reference to Perl-style regular expressions in the Perl regex documentation, or read about the Boost.Regex-specific options on the Boost documentation pages. You can also do a web search for "regular expression syntax" and find lots more, including step-by-step tutorials and learning resources, including ones that show you matchin results "live" as you change your syntax.


Regex to find invalid characters in filter or actions