Lambda表达式中使用正则表达式
某语句如果不用正则表达式:
string[] names = { "Tom", "Dick", "Harry", "Mary", "Jay" };
IEnumerable<string> query = names.Select(n => n.Replace("a", "").Replace("e", "").Replace("i", "").Replace("o", "").Replace("u", ""))
用正则表达式可简化为:
IEnumerable<string> query =names.select(n => Regex.Replace(n, "[aeiou]", ""));