I'm working on an application where the user's name is printed in a UILabel. I'm calling NSString's capitalizedString
method on the string that's being fed to the UILabel (so that the user's first, middle, and last names are capitalized). Here's some code for reference:
cell.textLabel.text = [theUsersName capitalizedString];
My problem is that I've encountered a user with Roman numerals in his/her name. The Roman numerals are being capitalized like so: 'Iii'.
My question is how can I detect Roman numerals and put them in all caps (III), while still maintaining the capitalizedString
functionality. Is a regex my only option?
EDIT
I've decided to go with Regular Expressions to solve this problem. However I'm having trouble implementing. I'm not too familiar with using NSRegularExpression, so could someone help out with the algorithm for solving this problem and point to some useful methods?