I believe something like this should work...
Code:
using System;
using System.Text.RegularExpressions;
namespace ConsoleApplication5
{
class Program
{
static void Main()
{
String filename1 = "The.Matrix.dvdrip.xvid";
Console.WriteLine(filename1 + " = " + GetName(filename1));
String filename2 = "Shrek.xvid.dvdrip";
Console.WriteLine(filename2 + " = " + GetName(filename2));
Console.Read();
}
static String GetName(String text)
{
Regex regex = new Regex("([a-zA-Z0-9\\.]+?).(xvid\\.dvdrip|dvdrip\\.xvid)", RegexOptions.IgnoreCase);
Match match = regex.Match(text);
return match.Success ? match.Groups[1].Value : null;
}
}
}