Roman Numerals

G'd Afternoon all. I have a reg-ex script for converting Roman numerals, but it seems to have a bug in it. In particular, the numerals "II, IV, VI VIII, XII and XIV come out as "Ii, Iv, Vi, Viii, Xii and Xiv". Here is the action, see if you can find the problem:

Action: Replace with regular expression
Field:_ALL
Regular expression: (?:^|\s|[|/)(?:C{0,3}|C)(?:X{0,3}|X[C])(?:V?I{0,3}|I[VX])(?:.|\s|)|$|:)
Replace matches with: $upper($0)
[ ] case-sensitive comparison

Before starting this thread, I searched the forum for other options, and found this post. The action is described as follows:

RE: Capitalize Roman Numerals up to 89.
Field:_Tag
re:(?<=[^\w']|_)(?:L?X{0,3}|XL)(?:V?I{0,3}|I[VX])(?=\W|_|$)
re:^(?:L?X{0,3}|XL)(?:V?I{0,3}|I[VX])(?=\W|_)
$upper($0)

I find this confusing, as there seems to be two different reg ex's here. If I discard the second one, it seems to work ok, but begs the question: what is the second line for? So, with only the first reg ex line included, is this a viable action?

Action: Replace with regular expression
Field:_ALL
Regular expression: (?<=[^\w']|_)(?:L?X{0,3}|XL)(?:V?I{0,3}|I[VX])(?=\W|_|$)
Replace matches with: $upper($0)
[ ] case-sensitive comparison

By the way, in case anyone should offer an alternative script, I should make it clear that I don't wish to convert large numerals, only up 100 at most. Thanks.

The problem might be your casing scheme.

See also there ...
Regular Expressions

... and for all possible information on the forum regarding roman numbers ...
http://www.google.de/search?q=site%3Aforum...de+roman+number

DD.20110318.1930.CET

I admit that it is not easy for a Mp3tag beginner to use example code snippets from other users and assemble them into its own personal work.

It is also not easy to decide, which code snippet is the one which will fit at the best into the own development or might be over the limits.

So I have created a Mp3tag mte export script, which visualizes the results of three attempts using regular epressions, which are able to upcase Roman Numerals in different quality.
The output from this profiling test can help to decide, what will the best for this case or for the other case.

To run the "Test.RomanNum.Upcase.mte" export script, there has to be selected only one file, which is totally not important.

Test.RomanNum.Upcase.zip (1.95 KB)

DD.20110320.0642.CET

Test.RomanNum.Upcase.zip (1.95 KB)

Fair play to you, DD, that's a very good idea. Of the three scripts, the second one suits my needs the best. The action I created from it looks like this:

Action type: Replace with regular expression
Field: _ALL
Regular expression: \b(?:L?X{0,3}|XL)(?:V?I{0,3}|I[VX])\b
Replace matches with: $upper($0)
[ ] case-sensitive comparison

Is this configuration correct? I've tested it and found no problems. Thanks.

I have been trying to get something like this to work for some time now ... you are a master as regex my friend ... even though you posted this long ago i just wanted to let you know that you have helped another person with your skills ... thanx a bunch!!

ra7h35m20s, better late than never!
I am pleased, thank you for your kind words.

And keep up Mp3tag-ing!

DD.20120224.2000.CET