开发者

Is it possible to write a regular expression for finding a typical file matching pattern in config file(C#)

开发者 https://www.devze.com 2022-12-26 10:19 出处:网络
Is it possible to write a regular expression for finding a typical file matc开发者_StackOverflow中文版hing pattern.

Is it possible to write a regular expression for finding a typical file matc开发者_StackOverflow中文版hing pattern.

e.g. File<13/04/2010>.txt should be picked up and not any other file.

i.e. Starting file name will be File followed by some dates and then the file extension.

If so, can we specify this pattern in the config file?

Looking for the solution in C#

Thanks


You can match

@"File\d{2}/\d{2}/\d{4}\.txt"

This matches File at first, then exactly two digits \d{2} followed by / ...
After the date, it matches a dot \. and the file-extension.

To match only files from april 2010 you can use something like @"File\d{2}/04/2010\.txt"

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号