ScanCharEscape() приватный Метод

private ScanCharEscape ( ) : char
Результат char
 internal static string Unescape(string input)
 {
     for (int i = 0; i < input.Length; i++)
     {
         if (input[i] == '\\')
         {
             StringBuilder builder = new StringBuilder();
             RegexParser parser = new RegexParser(CultureInfo.InvariantCulture);
             parser.SetPattern(input);
             builder.Append(input, 0, i);
             do
             {
                 i++;
                 parser.Textto(i);
                 if (i < input.Length)
                 {
                     builder.Append(parser.ScanCharEscape());
                 }
                 i = parser.Textpos();
                 int startIndex = i;
                 while ((i < input.Length) && (input[i] != '\\'))
                 {
                     i++;
                 }
                 builder.Append(input, startIndex, i - startIndex);
             }
             while (i < input.Length);
             return builder.ToString();
         }
     }
     return input;
 }
Пример #2
0
        /*
         * Escapes all metacharacters (including (,),[,],{,},|,^,$,*,+,?,\, spaces and #)
         */
        internal static String Unescape(String input)
        {
            for (int i = 0; i < input.Length; i++)
            {
                if (input[i] == '\\')
                {
                    StringBuilder sb = StringBuilderCache.Acquire();
                    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 StringBuilderCache.GetStringAndRelease(sb);
                }
            }

            return input;
        }