using System;
using System.Text.RegularExpressions;
public class Example
{
public static void Main()
{
string pattern = @"[\w\+\-]+\.\w+\.(?<EPOCH>\d+)(?<AV>\.av)?\.mat";
string input = @"AvAnalysisTill20Kepoch_onlyW.png
Program.30_07_2017_14_03_31.1.json
Program.30_07_2017_14_03_31.1.mat
Program.30_07_2017_14_03_31.10002.mat
Program.30_07_2017_14_03_31.10005.mat
Program.30_07_2017_14_03_31.10005.av.mat
Program.30_07_2017_14_03_31.10005.mat
Program.30_07_2017_14_03_31.10008.mat
Program.30_07_2017_14_03_31.10011.mat
Program.30_07_2017_14_03_31.10014.mat
Program.30_07_2017_14_03_31.10017.mat
Program.30_07_2017_14_03_31.1002.mat
Program.30_07_2017_14_03_31.10020.mat
Program.30_07_2017_14_03_31.10023.mat
Program.30_07_2017_14_03_31.10026.mat
Program.30_07_2017_14_03_31.10029.mat
Program.30_07_2017_14_03_31.10032.mat
Program.30_07_2017_14_03_31.10035.mat
Program.30_07_2017_14_03_31.10038.mat
Program.30_07_2017_14_03_31.10041.mat
Program.30_07_2017_14_03_31.10044.mat
Program.30_07_2017_14_03_31.10047.mat
Program.30_07_2017_14_03_31.1005.mat
UBUNTU_30x300w30r3E-2.02_08_2017_12_09_36.19950.mat
UBUNTU_30x300w30r3E-2.02_08_2017_12_09_36.19953.mat
UBUNTU_30x300w30r3E-2.02_08_2017_12_09_36.19956.mat
UBUNTU_30x300w30r3E-2.02_08_2017_12_09_36.19959.mat
UBUNTU_30x300w30r3E-2.02_08_2017_12_09_36.19962.mat
UBUNTU_30x300w30r3E-2.02_08_2017_12_09_36.19965.mat
UBUNTU_30x300w30r3E-2.02_08_2017_12_09_36.19968.mat
UBUNTU_30x300w30r3E-2.02_08_2017_12_09_36.19971.mat
UBUNTU_30x300w30r3E-2.02_08_2017_12_09_36.19974.mat
UBUNTU_30x300w30r3E-2.02_08_2017_12_09_36.19977.mat
UBUNTU_30x300w30r3E-2.02_08_2017_12_09_36.19980.mat
UBUNTU_30x300w30r3E-2.02_08_2017_12_09_36.19983.mat
UBUNTU_30x300w30r3E-2.02_08_2017_12_09_36.19986.mat
UBUNTU_30x300w30r3E-2.02_08_2017_12_09_36.19989.mat
UBUNTU_30x300w30r3E-2.02_08_2017_12_09_36.19992.mat
UBUNTU_30x300w30r3E-2.02_08_2017_12_09_36.19995.mat
UBUNTU_30x300w30r3E-2.02_08_2017_12_09_36.19998.mat
UBUNTU_30x300w30r3E-2.02_08_2017_12_09_36.20000.mat
";
foreach (Match m in Regex.Matches(input, pattern))
{
Console.WriteLine("'{0}' found at index {1}.", m.Value, m.Index);
}
}
}
Please keep in mind that these code samples are automatically generated and are not guaranteed to work. If you find any syntax errors, feel free to submit a bug report. For a full regex reference for C#, please visit: https://msdn.microsoft.com/en-us/library/system.text.regularexpressions.regex(v=vs.110).aspx