예제 #1
0
        public string GetRegex(RegexTypes type1, RegexTypes type2)
        {
            string regexp1 = GetRegex(type1);
            string regexp2 = GetRegex(type2);

            return("(" + regexp1 + ")|(" + regexp2 + ")");
        }
예제 #2
0
 public void SetRegex(RegexTypes type, string family, string regexp)
 {
     if (!m_regex.ContainsKey(type))
     {
         m_regex.Add(type, new Dictionary <string, string>());
     }
     m_regex[type][family] = regexp;
 }
예제 #3
0
        public bool IsMatch(string input, RegexTypes regexpType)
        {
            if (!m_regularExpressionBuffer.ContainsKey(regexpType))
            {
                string pattern = GetRegex(regexpType);
                Regex  regex   = new Regex(pattern, RegexOptions.Compiled);
                m_regularExpressionBuffer.Add(regexpType, regex);
            }

            return(m_regularExpressionBuffer[regexpType].IsMatch(input));
        }
예제 #4
0
        public bool HasRegexp(RegexTypes type)
        {
            if (!m_regex.ContainsKey(type))
            {
                return(false);
            }

            string familiy = FPGA.FPGA.Instance.Family.ToString();

            if (!m_regex[type].ContainsKey(familiy))
            {
                return(false);
            }
            return(true);
        }
예제 #5
0
        public string GetRegex(RegexTypes type)
        {
            if (FPGA.FPGA.Instance.Family.Equals(FPGATypes.FPGAFamily.Undefined))
            {
                throw new ArgumentException("No FPGA loaded");
            }

            if (!m_regex.ContainsKey(type))
            {
                throw new ArgumentException("No Regexp of type " + type + " found. Use SetRegexp command. Are you missing init.goa?");
            }

            string familiy = FPGA.FPGA.Instance.Family.ToString();

            if (!m_regex[type].ContainsKey(familiy))
            {
                throw new ArgumentException("No Regexp of type " + type + " found for FPGA family " + familiy + ". Use SetRegexp. Are you missing init.goa?");
            }
            return(m_regex[type][familiy]);
        }
 public RegexAttribute(RegexTypes type, string pattern = null)
 {
     Type = type;
     if (!string.IsNullOrEmpty(pattern))
     {
         Pattern = pattern;
     }
     if (Type == RegexTypes.Email)
     {
         Pattern = @"^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$";
     }
     else if (Type == RegexTypes.Phone)
     {
         Pattern = @"^(009665|9665|\+9665|05|5)(5|0|3|6|4|9|1|8|7)([0-9]{7})$";
     }
     else if (Type == RegexTypes.Barcode)
     {
         Pattern = @"^ASD-[A-Z]{3}-\d+";
     }
     else if (Type == RegexTypes.Number)
     {
         Pattern = @"^[0-9]+$";
     }
     else if (Type == RegexTypes.Text)
     {
         Pattern = @"^[0-9]+$";
     }
     else if (Type == RegexTypes.English)
     {
         Pattern = @"^[A-Za-z ]+$";
     }
     else if (Type == RegexTypes.NationalId)
     {
         pattern = @"^[0-9]{10}$";
     }
 }
예제 #7
0
 public List <Tuple <string, string> > GetRegexMultipairList(RegexTypes type1, RegexTypes type2)
 {
     return(GetRegexMultipairList(new Tuple <RegexTypes, RegexTypes>(type1, type2)));
 }