Community Patterns

Community Library Entry

4

Regular Expression
Created·2015-07-11 18:42
Flavor·PCRE (Legacy)

/
^(M{0,3})(C(?:D|M)|D?C{0,3})(X(?:L|C)|L?X{0,3})(I(?:V|X)|V?I{0,3})$
/
Open regex in editor

Description

Detects valid Roman numerals (up to 3999), and splits into 4 capture groups: thousands, hundreds, tens, and units.

Submitted by Terence Linnell