Is it possible to write a regular expression for finding a typical file matching pattern in config file(C#)
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"
精彩评论