简体   繁体   English

用于目录中文件名的正则表达式

[英]Regex for file name in a directory

I have two files in a directory. 我的目录中有两个文件。 FileAbc_1.xml and FileAbc.xml . FileAbc_1.xmlFileAbc.xml I want write a regex that only select FileAbc_1.xml . 我想编写一个仅选择FileAbc_1.xml的正则表达式。

My regex is : FileAbc.*.xml 我的正则表达式是: FileAbc.*.xml

It is picking up both file names but I only want FileAbc_1.xml . 它正在选择两个文件名,但是我只想要FileAbc_1.xml Any help would great favor. 任何帮助都会大有帮助。

这将为您工作FileAbc_ [0-9] +。xml

That should just be: FileAbc_\\d\\.xml 那应该是: FileAbc_\\d\\.xml

(assuming there's never more than one digit after the underscore) (假设下划线后的位数不超过一位数)

您可以将其用于任何以FileAbc开头并以XML FileAbc.+\\.xml结尾的内容。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM