C#检查字符串包含在一个字符串数组任何匹配 [英] C# Check if string contains any matches in a string array

查看:165
本文介绍了C#检查字符串包含在一个字符串数组任何匹配的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

什么是检查一个字符串包含在C#中的字符串数组任何匹配的最快方法?我可以用一个循环做到这一点,但我认为这将是太慢了。

What would be the fastest way to check if a string contains any matches in a string array in C#? I can do it using a loop, but I think that would be too slow.

推荐答案

您可以用正则表达式或语句组合字符串,然后一通这样做,但在技术上正则表达式仍然会内部进行循环。最终,循环是必要的。

You could combine the strings with regex or statements, and then "do it in one pass," but technically the regex would still performing a loop internally. Ultimately, looping is necessary.

这篇关于C#检查字符串包含在一个字符串数组任何匹配的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆