AddCategoryFromName() private méthode

private AddCategoryFromName ( string categoryName, bool invert, bool caseInsensitive, string pattern ) : void
categoryName string
invert bool
caseInsensitive bool
pattern string
Résultat void
Exemple #1
0
        internal static RegexCharClass CreateFromCategory(string categoryName, bool invert, bool caseInsensitive, string pattern)
        {
            RegexCharClass class2 = new RegexCharClass();

            class2.AddCategoryFromName(categoryName, invert, caseInsensitive, pattern);
            return(class2);
        }
        internal RegexNode ScanBackslash()
        {
            char ch;
            if (this.CharsRight() == 0)
            {
                throw this.MakeException(SR.GetString("IllegalEndEscape"));
            }
            switch ((ch = this.RightChar()))
            {
                case 'S':
                    this.MoveRight();
                    if (this.UseOptionE())
                    {
                        return new RegexNode(11, this._options, "\x0001\x0004\0\t\x000e !");
                    }
                    return new RegexNode(11, this._options, RegexCharClass.NotSpaceClass);

                case 'W':
                    this.MoveRight();
                    if (this.UseOptionE())
                    {
                        return new RegexNode(11, this._options, "\x0001\n\00:A[_`a{İı");
                    }
                    return new RegexNode(11, this._options, RegexCharClass.NotWordClass);

                case 'Z':
                case 'A':
                case 'B':
                case 'G':
                case 'b':
                case 'z':
                    this.MoveRight();
                    return new RegexNode(this.TypeFromCode(ch), this._options);

                case 'D':
                    this.MoveRight();
                    if (!this.UseOptionE())
                    {
                        return new RegexNode(11, this._options, RegexCharClass.NotDigitClass);
                    }
                    return new RegexNode(11, this._options, "\x0001\x0002\00:");

                case 'P':
                case 'p':
                {
                    this.MoveRight();
                    RegexCharClass class2 = new RegexCharClass();
                    class2.AddCategoryFromName(this.ParseProperty(), ch != 'p', this.UseOptionI(), this._pattern);
                    if (this.UseOptionI())
                    {
                        class2.AddLowercase(this._culture);
                    }
                    return new RegexNode(11, this._options, class2.ToStringClass());
                }
                case 'd':
                    this.MoveRight();
                    if (!this.UseOptionE())
                    {
                        return new RegexNode(11, this._options, RegexCharClass.DigitClass);
                    }
                    return new RegexNode(11, this._options, "\0\x0002\00:");

                case 's':
                    this.MoveRight();
                    if (this.UseOptionE())
                    {
                        return new RegexNode(11, this._options, "\0\x0004\0\t\x000e !");
                    }
                    return new RegexNode(11, this._options, RegexCharClass.SpaceClass);

                case 'w':
                    this.MoveRight();
                    if (this.UseOptionE())
                    {
                        return new RegexNode(11, this._options, "\0\n\00:A[_`a{İı");
                    }
                    return new RegexNode(11, this._options, RegexCharClass.WordClass);
            }
            return this.ScanBasicBackslash();
        }
 internal static RegexCharClass CreateFromCategory(string categoryName, bool invert, bool caseInsensitive, string pattern)
 {
     RegexCharClass class2 = new RegexCharClass();
     class2.AddCategoryFromName(categoryName, invert, caseInsensitive, pattern);
     return class2;
 }
Exemple #4
0
        /*
         * Scans chars following a '\' (not counting the '\'), and returns
         * a RegexNode for the type of atom scanned.
         */
        internal RegexNode ScanBackslash()
        {
            char ch;
            RegexCharClass cc;

            if (CharsRight() == 0)
                throw MakeException(SR.IllegalEndEscape);

            switch (ch = RightChar())
            {
                case 'b':
                case 'B':
                case 'A':
                case 'G':
                case 'Z':
                case 'z':
                    MoveRight();
                    return new RegexNode(TypeFromCode(ch), _options);

                case 'w':
                    MoveRight();
                    if (UseOptionE())
                        return new RegexNode(RegexNode.Set, _options, RegexCharClass.ECMAWordClass);
                    return new RegexNode(RegexNode.Set, _options, RegexCharClass.WordClass);

                case 'W':
                    MoveRight();
                    if (UseOptionE())
                        return new RegexNode(RegexNode.Set, _options, RegexCharClass.NotECMAWordClass);
                    return new RegexNode(RegexNode.Set, _options, RegexCharClass.NotWordClass);

                case 's':
                    MoveRight();
                    if (UseOptionE())
                        return new RegexNode(RegexNode.Set, _options, RegexCharClass.ECMASpaceClass);
                    return new RegexNode(RegexNode.Set, _options, RegexCharClass.SpaceClass);

                case 'S':
                    MoveRight();
                    if (UseOptionE())
                        return new RegexNode(RegexNode.Set, _options, RegexCharClass.NotECMASpaceClass);
                    return new RegexNode(RegexNode.Set, _options, RegexCharClass.NotSpaceClass);

                case 'd':
                    MoveRight();
                    if (UseOptionE())
                        return new RegexNode(RegexNode.Set, _options, RegexCharClass.ECMADigitClass);
                    return new RegexNode(RegexNode.Set, _options, RegexCharClass.DigitClass);

                case 'D':
                    MoveRight();
                    if (UseOptionE())
                        return new RegexNode(RegexNode.Set, _options, RegexCharClass.NotECMADigitClass);
                    return new RegexNode(RegexNode.Set, _options, RegexCharClass.NotDigitClass);

                case 'p':
                case 'P':
                    MoveRight();
                    cc = new RegexCharClass();
                    cc.AddCategoryFromName(ParseProperty(), (ch != 'p'), UseOptionI(), _pattern);
                    if (UseOptionI())
                        cc.AddLowercase(_culture);

                    return new RegexNode(RegexNode.Set, _options, cc.ToStringClass());

                default:
                    return ScanBasicBackslash();
            }
        }