Bart Van Den Boomen Bart Van Den Boomen - 1 month ago 23
C# Question

Regex in c# to find files in log

I'm trying to find some filenames that are written into a logfile that end on 'K.TIF'.

I'm trying to find:



As I'm terrible in regex's, I tried this:

Regex.Match(line, @"([A-Z0-9]+){23}\.TIF", RegexOptions.IgnoreCase);
Regex.Match(line, @"(?<=\\)(.>)(?=K\.TIF){23}", RegexOptions.IgnoreCase);

The first one is terrible, doesn't perform and gives bad results.

The second one actually gives all the TIF that end on Z.TIF if I change K\ to Z. However, it does not find any K.TIF's with the current regex.


This seems to work for me:


It searches for the last slash and then captures the word characters followed by K.TIF. Example: