我想从以下文本中提取文件名 13572_BranchInformationReport_2012-06-28.zip -
1:30","/icons/def13572_BranchInformationReport_2012-06-28.zip","13572_BranchInformationReport_2012-06-28.zip",0,"184296","Jun 28
我使用的正则表达式代码是:
var fileNames = from Match m in Regex.Matches(pageSource, @"[0-9]+_+[A-Za-z]+_+[0-9]+-+[0-9]+-+[0-9]+.+(acc|zip|app|xml|def|enr|exm|fpr|pnd|trm)")
select m.Value;
哪个应该可以正常工作。
我错过了什么?
请您参考如下方法:
您需要转义 .在正则表达式的中间,因为 .匹配任何字符。
@"[0-9]+_+[A-Za-z]+_+[0-9]+-+[0-9]+-+[0-9]+\.+(acc|zip|app|xml|def|enr|exm|fpr|pnd|trm)"
