public override int Match(string textToMatch, int matchAtIndex)
{
int length = 0;
int textLength = textToMatch.Length;
while (matchAtIndex + length != textLength)
{
if (textToMatch[matchAtIndex + length] == EndChar &&
(matchAtIndex + length < textLength - 1 && textToMatch[matchAtIndex + length + 1] == EndChar))
{
length++;
}
else if (textToMatch[matchAtIndex + length] == EndChar &&
(matchAtIndex + length == textLength - 1 || textToMatch[matchAtIndex + length + 1] != EndChar))
return length + 1;
length++;
}
return 0;
}
}