Пример #1
0
        private Category ParseUnicodeCategory()
        {
            if (pattern[ptr++] != '{')
            {
                throw NewParseException("Incomplete \\p{X} character escape.");
            }

            string name = ParseName(pattern, ref ptr);

            if (name == null)
            {
                throw NewParseException("Incomplete \\p{X} character escape.");
            }

            Category cat = CategoryUtils.CategoryFromName(name);

            if (cat == Category.None)
            {
                throw NewParseException("Unknown property '" + name + "'.");
            }

            if (pattern[ptr++] != '}')
            {
                throw NewParseException("Incomplete \\p{X} character escape.");
            }

            return(cat);
        }