/*
* Escapes all metacharacters (including (,),[,],{,},|,^,$,*,+,?,\, spaces and #)
*/
internal static string Unescape(string input)
{
for (int i = 0; i < input.Length; i++)
{
if (input[i] == '\\')
{
var sb = new StringBuilder();
RegexParser p = new RegexParser(CultureInfo.InvariantCulture);
int lastpos;
p.SetPattern(input);
sb.Append(input, 0, i);
do
{
i++;
p.Textto(i);
if (i < input.Length)
sb.Append(p.ScanCharEscape());
i = p.Textpos();
lastpos = i;
while (i < input.Length && input[i] != '\\')
i++;
sb.Append(input, lastpos, i - lastpos);
} while (i < input.Length);
return sb.ToString();
}
}
return input;
}