Converting Roman numerals to decimal
If you have only valid Roman numbers you could use a simpler algorithms.  (i.e IIV is invalid )


  
  The symbols "I", "X", "C", and "M" can be repeated three times in succession, but no more. (They may appear more than three times if
  they appear non-sequentially, such as XXXIX.) "V", "L", and "D" can
  never be repeated. A common exception to this is the use of IIII on
  clocks; see below.
  "I" can be subtracted from "V" and "X" only. "X" can be subtracted from "L" and "C" only. "C" can be subtracted from "D" and "M" only.
  "V", "L", and "D" can never be subtracted
  Only one small-value symbol may be subtracted from any large-value symbol.
  


Just (string-)replace IV by IIII, IX by VIIII and so on. Afterwards you just have to sum the numbers from left to right.