private string ReplaceAnimalsWithHorsesInFact(string fact) { var animals = _animalWords.GetWords(); var horseFact = fact; horseFact = Regex.Replace(horseFact, $"\\b({string.Join('|', animals)})(s?)\\b", "horse$2"); horseFact = Regex.Replace(horseFact, $"\\b({string.Join('|', animals.Capitalise())})(s?)\\b", "Horse$2"); horseFact = Regex.Replace(horseFact, $"\\b({string.Join('|', animals.ToUpper())})(S?)\\b", "HORSE$2"); return(horseFact); }
public async Task <GetRandomVeganIpsumParagraphResponse> Execute() { var foodIpsum = await _foodIpsumGateway.GetFoodIpsum(); var meats = _meatWords.GetWords(); var parapraph = foodIpsum.Paragraph; parapraph = Regex.Replace(parapraph, $"\\b({string.Join('|', meats)})(s?)\\b", "banana$2"); parapraph = Regex.Replace(parapraph, $"\\b({string.Join('|', meats.Capitalise())})(s?)\\b", "Banana$2"); return(new GetRandomVeganIpsumParagraphResponse { VeganIpsumParagraph = parapraph }); }