Some help debugging regex please

I make use of an action in conjunction with a regex to generate Firstlettercaps strings for all words in a string, excepting a predefined list of words which should always be formatted lowercase. The regex works for the most part, but I do get exceptions, e.g. "I'm" and/or "i'm" returns "I'M" instead of "I'm". As it turns out, I'm unable to spot my error, so I'm hoping someone out there can give me a hand. Here's the code:

Firstly, I apply a case conversion Mixed case action, with words beginning after any of: .([/"

Then I apply a regex as follows:
replace matches with $upper($0)

followed by another regex as follows:
replace matches with $lower($0)

Hmm, now if only I could edit the topic header or delete the post I'd correct the subject error!

Your actions work for the most cases, and you got only a few exceptions?
Then add some action to handle the exceptions, e. g. simply replace "I'M" with "I'm".


Thx, that'd work, but the purist in me wants to know what's wrong with the regex :wink:

Just a quick hack, not tested thoroughly ...

$regexp('I''''m so dizzy about mclxi''''s letters','[^''''|\b](?i:(?=[MDCLXVI])((M{0,3})((C[DM])|(D?C{0,3}))?((X[LC])|(L?XX{0,2})|L)?((I[VX])|(V?(II{0,2}))|V)?))[\b|^'''']','\U$0')

I'm so dizzy about mclxi's letters
I'm so dizzy about MCLXI's letters

Same as above wrapped into an action:
Action #1
Actiontype 4: Replace with regular expression
Field: EGD
Regular expression: ^'|\b[\b|^']
Replace matches with: \U$0

[_] Case sensitive comparison

Edit. DD.20091208.0710