public bool MatchNationalNumber(string number, PhoneNumberDesc numberDesc, bool allowPrefixMatch)
        {
            var nationalNumberPattern = numberDesc.NationalNumberPattern;

            // We don't want to consider it a prefix match when matching non-empty input against an empty
            // pattern.
            return(nationalNumberPattern.Length > 0 &&
                   Match(number, RegexCache.GetPatternForRegex(nationalNumberPattern), allowPrefixMatch));
        }
Exemplo n.º 2
0
        public void TestRegexInsertion()
        {
            const String regex1 = "[1-5]";
            const String regex2 = "(?:12|34)";
            const String regex3 = "[1-3][58]";

            regexCache.GetPatternForRegex(regex1);
            Assert.That(regexCache.ContainsRegex(regex1));

            regexCache.GetPatternForRegex(regex2);
            Assert.That(regexCache.ContainsRegex(regex2));
            Assert.That(regexCache.ContainsRegex(regex1));

            regexCache.GetPatternForRegex(regex1);
            Assert.That(regexCache.ContainsRegex(regex1));

            regexCache.GetPatternForRegex(regex3);
            Assert.That(regexCache.ContainsRegex(regex3));

            Assert.False(regexCache.ContainsRegex(regex2));
            Assert.That(regexCache.ContainsRegex(regex1));
        }