internal static string EscapeBracketExpressionSpecialChars(string chars)
{
StringBuilder sb = new StringBuilder();
for (int i = 0; i < chars.Length; i++)
{
char ch = chars[i];
switch (ch)
{
// case '^': // not necessary, not at the beginning have no special meaning
case '\\':
case ']':
case '-':
sb.Append('\\');
goto default;
default:
sb.Append(ch);
break;
}
}
return sb.ToString();
}