public int FindDelimAfterWhitespace(string str, int idx, params char[] delims)
{
List<int> indices = new List<int>(delims.Length);
foreach (char d in delims)
{
int next = str.IndexOf(d, idx);
if (next < 0)
continue;
//if we find a delim, make sure it is prefixed by whitespace
if (next > 0)
{
//if this one isn't prefixed by whitespace, check the next one
bool done = char.IsWhiteSpace(str[next - 1]);
while (!done)
{
next = str.IndexOf(d, next + 1);
done = (next == -1) || char.IsWhiteSpace(str[next - 1]);
}
//didn't find a better one
if (next < 0)
continue;
//did find it
}
indices.Add(next);
}
return (indices.Count > 0) ? indices.Min() : -1;
}