Esempio n. 1
0
        private static void UpperCaseRomanNumeral(string item, ref string result)
        {
            CultureInfo cultureInfo = CultureInfo.InvariantCulture;
            TextInfo    textInfo    = cultureInfo.TextInfo;

            List <string> resultList  = new List <string>();
            Regex         regexRoman  = new Regex(@"(\b(M{0,4}(CM|CD|D?C{0,3})(XC|XL|L?X{0,3})(IX|IV|V?I{0,3})|[IDCXMLV])\b)");
            Match         matchResult = regexRoman.Match(item);

            while (matchResult.Success)
            {
                resultList.Add(matchResult.Value);
                matchResult = matchResult.NextMatch();
            }
            resultList = resultList.Where(x => !string.IsNullOrEmpty(x)).ToList();

            foreach (string Roman in resultList)
            {
                if (!string.IsNullOrEmpty(Roman))
                {
                    string RomanResult = textInfo.ToTitleCase(Roman.ToLower());
                    result = result.Replace(RomanResult, Roman);
                }
            }
        }