CodiceSoftware.VsTitle4Plastic.WindowTitleBuilder.GetMatchingPattern C# (CSharp) Method

GetMatchingPattern() private method

private GetMatchingPattern ( string currentTitle, string selectorPattern ) : Match
currentTitle string
selectorPattern string
return System.Text.RegularExpressions.Match
        Match GetMatchingPattern(string currentTitle, string selectorPattern)
        {
            DTE2 dte = DTEService.Get();

            Match match = new Regex(
                  @"^(.*) - (" + dte.Name + ".*) " + Regex.Escape(string.Format("{0} {1}", selectorPattern, "(.*)")) + "$",
                  RegexOptions.RightToLeft).Match(currentTitle);

            if (match.Success)
                return match;

            match = new Regex(@"^(.*) - (" + dte.Name + @".* \(.+\)) \(.+\)$", RegexOptions.RightToLeft).Match(currentTitle);

            if (match.Success)
                return match;

            match = new Regex(@"^(.*) - (" + dte.Name + ".*)$", RegexOptions.RightToLeft).Match(currentTitle);

            if (match.Success)
                return match;

            match = new Regex(@"^(" + dte.Name + ".*)$", RegexOptions.RightToLeft).Match(currentTitle);
            return match;
        }