Skip to content

Commit

Permalink
Organize
Browse files Browse the repository at this point in the history
  • Loading branch information
faisalr committed Feb 13, 2014
1 parent 344bf5c commit c14fdea
Showing 1 changed file with 17 additions and 17 deletions.
34 changes: 17 additions & 17 deletions src/Humanizer/RomanNumeralExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,28 +11,23 @@ public static class RomanNumeralExtensions

private static readonly Dictionary<string, int> romanNumerals = new Dictionary<string, int>(NumberOfRomanNumeralMaps)
{
{ "M", 1000 },
{ "CM", 900 },
{ "D", 500 },
{ "CD", 400 },
{ "C", 100 },
{ "XC", 90 },
{ "L", 50 },
{ "XL", 40 },
{ "X", 10 },
{ "IX", 9 },
{ "V", 5 },
{ "IV", 4 },
{ "M", 1000 },
{ "CM", 900 },
{ "D", 500 },
{ "CD", 400 },
{ "C", 100 },
{ "XC", 90 },
{ "L", 50 },
{ "XL", 40 },
{ "X", 10 },
{ "IX", 9 },
{ "V", 5 },
{ "IV", 4 },
{ "I", 1 }
};

private static readonly Regex validRomanNumeral = new Regex("^(?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)?))$", RegexOptions.None);

private static bool IsInvalidRomanNumeral(string value)
{
return !validRomanNumeral.IsMatch(value);
}

/// <summary>
/// Converts Roman numbers into integer
/// </summary>
Expand Down Expand Up @@ -100,5 +95,10 @@ public static string ToRoman(this int value)

return sb.ToString();
}

private static bool IsInvalidRomanNumeral(string value)
{
return !validRomanNumeral.IsMatch(value);
}
}
}

0 comments on commit c14fdea

Please sign in to comment.