How to match roman numerals using Regex

To match roman numerals using Regex you can use the following regex.
The First Group should contain the Roman Numeral.

^(?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)?))$

Please Share us:
Please rate this snippet

4 thoughts on “How to match roman numerals using Regex

Leave a Reply