
我在C#,我不知道从哪里开始.
解决方法 为什么不使用liNQ?Dictionary<string,string> myCollection = new Dictionary<string,string>();myCollection.Add("(.*)orange(.*)","Oranges are a fruit.");myCollection.Add("(.*)apple(.*)","Apples have pips.");myCollection.Add("(.*)dog(.*)","Dogs are mammals.");// ...string input = "tell me about apples and oranges";var results = from result in myCollection where Regex.Match(input,result.Key,RegexOptions.Singleline).Success select result;foreach (var result in results){ Console.Writeline(result.Value);}// OUTPUT://// Oranges are a fruit.// Apples have pips. 总结 以上是内存溢出为你收集整理的匹配C#中字典的正则表达式全部内容,希望文章能够帮你解决匹配C#中字典的正则表达式所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)