tags:

views:

41

answers:

1

Is it possible to write a regular expression for finding a typical file matching 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

+1  A: 

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"

tanascius
That will never match the < and >.
Elise van Looij
I thought the `<` and `>` exist to mark the date as an example. That's why I left them out intentionally ...
tanascius
Can't use them as file name characters anyway (or / for that matter)
Alex K.
tanascius is correct. <> is just the place holder
Thinking
@Alex: yes you are right - @Thinking: `/` can not be used as a character for filenames - didn't realize this ...
tanascius