private MatchingTag GetFirstMatchingTag(string input)
        {
            var minIndex = input.Length;
            var result = new MatchingTag();
            foreach (var bbTag in tags)
            {
                var openTagRegex = new Regex(bbTag.GetOpenHtmlTagPattern(DirectionMode.HtmlToBB));
                var openTagMatch = openTagRegex.Match(input);
                if (openTagMatch.Success && openTagMatch.Index < minIndex)
                {
                    minIndex = openTagMatch.Index;
                    result.Tag = bbTag;
                    result.TagType = TagType.Open;
                    result.Match = openTagMatch;
                }

                if (!bbTag.RequiresClosingTag) continue;

                var closeTagRegex = new Regex(bbTag.GetCloseHtmlTagPattern());
                var closeTagMatch = closeTagRegex.Match(input);
                if (closeTagMatch.Success && closeTagMatch.Index < minIndex)
                {
                    minIndex = closeTagMatch.Index;
                    result.Tag = bbTag;
                    result.TagType = TagType.Close;
                    result.Match = closeTagMatch;
                }
            }

            return result;
        }
        private MatchingTag GetFirstMatchingTag(string input)
        {
            var minIndex = input.Length;
            var result   = new MatchingTag();

            foreach (var bbTag in tags)
            {
                var openTagRegex = new Regex(bbTag.GetOpenHtmlTagPattern(DirectionMode.HtmlToBB));
                var openTagMatch = openTagRegex.Match(input);
                if (openTagMatch.Success && openTagMatch.Index < minIndex)
                {
                    minIndex       = openTagMatch.Index;
                    result.Tag     = bbTag;
                    result.TagType = TagType.Open;
                    result.Match   = openTagMatch;
                }

                if (!bbTag.RequiresClosingTag)
                {
                    continue;
                }

                var closeTagRegex = new Regex(bbTag.GetCloseHtmlTagPattern());
                var closeTagMatch = closeTagRegex.Match(input);
                if (closeTagMatch.Success && closeTagMatch.Index < minIndex)
                {
                    minIndex       = closeTagMatch.Index;
                    result.Tag     = bbTag;
                    result.TagType = TagType.Close;
                    result.Match   = closeTagMatch;
                }
            }

            return(result);
        }