According to Dr. Math
(http://mathforum.org/library/drmath/view/57546.html):
* I, X, C, and M cannot be repeated more than 3 times.
* V, L and D cannot be repeated.
* numerals are in descending order left to right except for in the
pairs IV, IX, XL, XC, CD, CM ie. /i[xv]/, /x[cl]/, /c[dm]/
* Roman numbers are made by concatenating roman number representing
individual digits in a decimal number
/^m?m?m?(c[md]|d?c{0,3})(x[lc]|l?x{0,3})(i[xv]|v?i{0,3})$/
# 1000s 100s 10s 1s #
might one such regexp that matches iff $_ is a roman numeral.
This turns out to be exactly the same regular expression that is used by
Roman.pm from CPAN to decide if a string isroman.
Offcourse it also matches some english words such as "mix" and proper
names like Vi. Running it against dict/words and the moby word list found
these to be the only cases though.
/jas
Bart Lateur <[EMAIL PROTECTED]> writes:
> Can someone come up with a (nice) regex that matches only Roman
> numerals?
>
> I'm trying to include proper case conversion to title case in a script,
> and it should turn a movie title like "HALLOWEEN II" into "Halloween
> II", not "Halloween Ii".
>
> --
> Bart.
>
>
--
Jasvir Nagra
http://www.cs.auckland.ac.nz/~jas/
echo [91PP93P[dx]P]dx|dc