Beispiel #1
0
    public override void Start(string input)
    {
        this.input = input;
        matches    = RegexUtilities.GetMatches(input, @"(\r*\n *){3,}");
        for (int i = 0; i < matches.Count; i++)
        {
            bool matchDeleted = false;
            for (int j = 0; j < matches.Count && !matchDeleted; j++)
            {
                if (i == j)
                {
                    continue;
                }
                if (matches[i].index >= matches[j].index && matches[i].value.Length < matches[j].value.Length)
                {
                    matches.RemoveAt(i);
                    matchDeleted = true;
                }
            }
        }

        // Get preview.
        Preview = input;
        for (int i = matches.Count - 1; i >= 0; i--)
        {
            Preview = Preview.Insert(matches[i].index + matches[i].value.Length, "←]</color>");
            Preview = Preview.Insert(matches[i].index, "<color=red>[→");
        }
    }
Beispiel #2
0
    public void Find(string input)
    {
        groups.Clear();
        openings = RegexUtilities.GetMatches(input, opening);
        closings = RegexUtilities.GetMatches(input, closing);

        // For each closing, find the closest opening.
        for (int i = 0; i < closings.Count; i++)
        {
            bool openingFound = false;
            for (int j = 0; j < openings.Count && !openingFound; j++)
            {
                if (openings[j].index > closings[i].index || j >= openings.Count - 1)
                {
                    openingFound = true;
                    groups.Add(new Group(openings[openings[j].index > closings[i].index ? j - 1 : j], closings[i]));
                }
            }
        }
    }