Пример #1
0
 /// <summary>
 /// Matches a phone number.
 /// </summary>
 /// <param name="pattern">The pattern.</param>
 /// <param name="kind">The kind.</param>
 /// <returns>Returns a <see cref="PatternExpression"/>.</returns>
 public static PatternExpression Phone(this PatternExpression pattern, PhoneNumberKind kind = PhoneNumberKind.Default)
 {
     switch (kind)
     {
     default:
         return(new PatternExpression(pattern.Build() + @"^((\(\d{3}\) ?)|(\d{3}-))?\d{3}-\d{4}$"));
     }
 }
Пример #2
0
        public override String ToString()
        {
            if (IsEmpty)
            {
                return("0");
            }

            PhoneNumberKind kind        = Kind;
            int             countryCode = CountryCode;

            if (kind == PhoneNumberKind.MobilePhone)
            {
                return("+" + countryCode + '-' + MobilePhone);
            }
            else if (kind == PhoneNumberKind.FixedPhone)
            {
                return("+" + countryCode + '-' + AreaCode + '-' + FixedPhone);
            }
            else
            {
                return("UnknownKind" + kind);
            }
        }
Пример #3
0
 /// <summary>
 /// Matches a phone number.
 /// </summary>
 /// <param name="kind">The kind.</param>
 /// <returns>Returns a <see cref="PatternExpression"/>.</returns>
 public static PatternExpression Phone(PhoneNumberKind kind = PhoneNumberKind.Default)
 {
     return(PatternExpression.Empty.Phone(kind));
 }