Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/337.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/9/extjs/3.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# 与任何.aspx url匹配的正则表达式_C#_Regex - Fatal编程技术网

C# 与任何.aspx url匹配的正则表达式

C# 与任何.aspx url匹配的正则表达式,c#,regex,C#,Regex,我在阅读的文本中提到,以下正则表达式匹配任何.aspx url: @“?i:^.*\.aspx.*$” 我不明白?我:^在匹配时做了什么。请。解释它在URL中匹配的部分,如http://localhost:2447/Out.aspx,https://msdn.microsoft.com/en-us/library/88c54tsw.aspx?i表示忽略大小写。你的图案也有一些不必要的填充物。如果只想检查字符串是否包含.aspx,请使用以下命令: (?i)\.aspx // Match: htt

我在阅读的文本中提到,以下正则表达式匹配任何.aspx url:

@“?i:^.*\.aspx.*$”


我不明白
?我:^
在匹配时做了什么。请。解释它在URL中匹配的部分,如
http://localhost:2447/Out.aspx
https://msdn.microsoft.com/en-us/library/88c54tsw.aspx

?i
表示忽略大小写。你的图案也有一些不必要的填充物。如果只想检查字符串是否包含
.aspx
,请使用以下命令:

(?i)\.aspx

// Match:
http://localhost:2447/Out.aspx
http://localhost:2447/Out.AsPx/suburl
https://msdn.microsoft.com/en-us/library/88c54tsw.aspx

请不要使用文本说话,世界各地有很多人,有些人可能很难理解。System.IO.Path.GetExtension(新Uri(url).LocalPath)检查文件扩展名的最佳正则表达式是“\b\w+\(?=aspx)\w+\b”