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

4 thought on “How to match roman numerals using Regex”

Leave a Reply