Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/326.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/regex/18.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 如何在C中用正则表达式测试字符串?_C#_Regex - Fatal编程技术网

C# 如何在C中用正则表达式测试字符串?

C# 如何在C中用正则表达式测试字符串?,c#,regex,C#,Regex,我有像images.myweb.com/files或test.com/images这样的URL链接 我想检查URL是否包含 带有正则表达式的.com/or.in/or.net/or.org/。 如何使用C正则表达式实现这一点 不要使用正则表达式,只需使用带有 可能与a结合使用以绕过大小写敏感度。不要使用正则表达式,只需使用带有a的类即可 可能与a结合使用以绕过区分大小写。lst是您的字符串列表,如lst=new[]{.com/,.in/,.net/,.org/},然后您可以使用Linq: lst

我有像images.myweb.com/files或test.com/images这样的URL链接 我想检查URL是否包含 带有正则表达式的.com/or.in/or.net/or.org/。
如何使用C正则表达式实现这一点

不要使用正则表达式,只需使用带有


可能与a结合使用以绕过大小写敏感度。

不要使用正则表达式,只需使用带有a的类即可


可能与a结合使用以绕过区分大小写。

lst是您的字符串列表,如lst=new[]{.com/,.in/,.net/,.org/},然后您可以使用Linq:

lst.Any(x=>myString.Contains(x))
如果您希望字符串以以下项目结尾,请执行以下操作:

lst.Any(x=>myString.EndsWith(x))

lst是您的字符串列表,如lst=new[]{.com/,.in/,.net/,.org/},然后您可以使用Linq执行此操作:

lst.Any(x=>myString.Contains(x))
如果您希望字符串以以下项目结尾,请执行以下操作:

lst.Any(x=>myString.EndsWith(x))

所以,你想要一个正则表达式,即使它不是最好的工作?与其告诉人们如何去做,不如问什么是实现你所需要的最好的方法。所以,你想要一个正则表达式,即使它不是工作中最好的东西?与其告诉人们如何去做,不如问什么是实现你所需要的最好方法。用你的例子,www.computer.nl会发生什么?用你的例子,www.computer.nl会发生什么?