Don't forget that your character class indicates that there is
one Roman numeral, not multiple. Also, you might want to add
^
and
$
at the beginning/end to indicate that the string starts/ends.
^[ivxlcdm]+|[IVXLCDM]+$
The
+
indicates: one or more.
If you allow that lowercase and uppercase Roman numerals are mixed, put them all in one character class:
^[ivxlcdmIVXLCDM]+$