internal string AnalizePattern(string pat) { int length1 = pat.Length; char[] destination = new char[length1 + 1]; pat.CopyTo(0, destination, 0, length1); destination[length1] = char.MinValue; char[] chArray1 = new char[length1 + 1]; int length2 = 0; int num1 = 0; int index1 = 0; while (index1 < length1) { if (destination[index1] == '*' || destination[index1] == '%') { while ((destination[index1] == '*' || destination[index1] == '%') && index1 < length1) { ++index1; } if (index1 < length1 && length2 > 0 || num1 >= 2) { throw InvalidExpressionException.InvalidPattern(pat); } ++num1; } else if (destination[index1] == '[') { int num2 = index1 + 1; if (num2 >= length1) { throw InvalidExpressionException.InvalidPattern(pat); } char[] chArray2 = chArray1; int index2 = length2++; char[] chArray3 = destination; int index3 = num2; int index4 = index3 + 1; int num3 = (int)chArray3[index3]; chArray2[index2] = (char)num3; if (index4 >= length1) { throw InvalidExpressionException.InvalidPattern(pat); } if (destination[index4] != ']') { throw InvalidExpressionException.InvalidPattern(pat); } index1 = index4 + 1; } else { chArray1[length2++] = destination[index1]; ++index1; } } string str = new string(chArray1, 0, length2); if (num1 == 0) { this.kind = 4; return(str); } if (length2 > 0) { if (destination[0] == '*' || destination[0] == '%') { if (destination[length1 - 1] == '*' || destination[length1 - 1] == '%') { this.kind = 3; return(str); } this.kind = 2; return(str); } this.kind = 1; return(str); } this.kind = 5; return(str); }
internal string AnalizePattern(string pat) { int count = pat.Length; char[] destination = new char[count + 1]; pat.CopyTo(0, destination, 0, count); destination[count] = '\0'; string text = null; char[] chArray2 = new char[count + 1]; int length = 0; int wildCharOccurences = 0; int index = 0; while (index < count) { if ((destination[index] == '*') || (destination[index] == '%')) { while (((destination[index] == '*') || (destination[index] == '%')) && (index < count)) { // eat wild chars index++; } if (((index < count) && (length > 0)) || (wildCharOccurences >= 2)) { // max 2 wild chars are allowed throw InvalidExpressionException.InvalidPattern(pat); } wildCharOccurences++; } else if (destination[index] == '[') { index++; if (index >= count) { throw InvalidExpressionException.InvalidPattern(pat); } chArray2[length++] = destination[index++]; if (index >= count) { throw InvalidExpressionException.InvalidPattern(pat); } if (destination[index] != ']') { throw InvalidExpressionException.InvalidPattern(pat); } index++; } else { chArray2[length++] = destination[index]; index++; } } text = new string(chArray2, 0, length); if (wildCharOccurences == 0) { this.kind = match_exact; return(text); } if (length > 0) { if ((destination[0] == '*') || (destination[0] == '%')) { if ((destination[count - 1] == '*') || (destination[count - 1] == '%')) { this.kind = match_middle; return(text); } this.kind = match_right; return(text); } this.kind = match_left; return(text); } this.kind = match_all; return(text); }