Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/186.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
ASP.NET中文件名的正则表达式_Asp.net_.net_Regex - Fatal编程技术网

ASP.NET中文件名的正则表达式

ASP.NET中文件名的正则表达式,asp.net,.net,regex,Asp.net,.net,Regex,我有一个表单,我上传了一个文件,我必须验证文件名的格式是input##.txt,其中##是数字 到目前为止,我在上传输入上有一个验证器,我找到的正则表达式是input\d{2}\.txt,但这还不够,因为FileUpload控件的文件名如下所示: C:\Documents and Settings\xyz\Desktop\input01.txt 我只需要验证带有input01.txt的部件 有人能帮我吗?试试这个: var fileName = Path.GetFileName(path); v

我有一个表单,我上传了一个文件,我必须验证文件名的格式是
input##.txt
,其中
##
是数字

到目前为止,我在上传输入上有一个验证器,我找到的正则表达式是
input\d{2}\.txt
,但这还不够,因为FileUpload控件的文件名如下所示:

C:\Documents and Settings\xyz\Desktop\input01.txt

我只需要验证带有
input01.txt
的部件

有人能帮我吗?

试试这个:

var fileName = Path.GetFileName(path);
var regex = new Regex("input\d{2}.txt", RegexOptions.IgnoreCase);
var isValid = regex.Matches(fileName);