protected static string ExtractAndUnescapeString(string text, ref int start, params char[] specialChars)
{
StringBuilder buffer = new StringBuilder();
int index = start;
bool escaped = false;
while (index < text.Length)
{
char ch = text[index++];
if (!escaped)
{
// skip any escape character but keep the one after it.
if (ch == specialChars[0])
{
escaped = true;
continue;
}
// terminate on any special char other than the escape char.
for (int jj = 1; jj < specialChars.Length; jj++)
{
if (specialChars[jj] == ch)
{
start = index-1;
return buffer.ToString();
}
}
}
buffer.Append(ch);
escaped = false;
}
start = text.Length;
return buffer.ToString();
}
#endregion