public string Apply(string word) { if (!regex.IsMatch(word)) return null; string replace = regex.Replace(word, replacement); if (word == word.ToUpper()) replace = replace.ToUpper(); return replace; } }