Exemplo n.º 1
0
        public SRex NotFollowedBy(EPat cp)
        {
            string nextPattern = TranslateInRegEx(cp);

            if (!nextPattern.StartsWith("["))
            {
                throw new Exception("'Not' isn't suitable for: " + cp.ToString());
            }
            nextPattern = "[^" + nextPattern.Substring(1);
            return(AddNewPattern(nextPattern, false, ""));
        }
Exemplo n.º 2
0
        private string TranslateInRegEx(EPat cp)
        {
            switch (cp)
            {
            case EPat.NUMBERS:
                return("[0-9]");

            case EPat.LETTERS_UCASE:
                return("[A-Z]");

            case EPat.LETTERS_LCASE:
                return("[a-z]");

            //case EPat.LETTERS:
            //    return "[A-Za-z]";
            //case EPat.LETTERS_NUMS:
            //    return "[A-Za-z0-9]";
            case EPat.SPACE:
                return("[ ]");

            case EPat.ANY_SPACE:
                return(@"\s");

            case EPat.ANY_CHAR:
                return(".");

            case EPat.TAB:
                return(@"\t");

            case EPat.NEWLINE:
                return(@"\n");

            case EPat.CARRIAGE_RETURN:
                return(@"\r");

            default:
                throw new Exception("Unrecognize " + cp.ToString());
            }
        }