Esempio n. 1
0
def test_phone_numbers():
    """US phone numbers only."""

    assert v.phone_number("919-555-1212")
    assert v.phone_number("(919) 555-1212")
    assert v.phone_number("9195551212")
    assert v.phone_number("919.555.1212")
    assert v.phone_number("919 555-1212")
    assert not v.phone_number("")
    assert not v.phone_number("555-121")
    assert not v.phone_number("1212")
    assert not v.phone_number("mobile")
Esempio n. 2
0
def test_phone_numbers():
    """US phone numbers only."""

    assert v.phone_number("919-555-1212")
    assert v.phone_number("(919) 555-1212")
    assert v.phone_number("9195551212")
    assert v.phone_number("919.555.1212")
    assert v.phone_number("919 555-1212")
    assert not v.phone_number("")
    assert not v.phone_number("555-121")
    assert not v.phone_number("1212")
    assert not v.phone_number("mobile")
Esempio n. 3
0
def phone_number(n):
    if v.phone_number(n):
        number = re.sub(r'[^0-9]', '', n)
        return {'area_code' : number[0:3], 'number' : number[3:6]+'-'+number[6:10]}

    else:
        return None
Esempio n. 4
0
def phone_number(string):
    phone_book = {}
    if not v.phone_number(string):
        return None
    ret = re.sub(r'[^0-9]','',string)
    phone_book['area_code'] = ret[:3]
    phone_book['number'] = '{}-{}'.format(ret[3:6],ret[6:])
    return phone_book
def phone_number(x):
    if v.phone_number(x):
        number = re.sub(r'[^0-9]', '', x)
        ret = {'area_code': number[0:3], 'number': number[3:6]+'-'+number[6:10]}
        #print(ret)
        return ret
    else:
        return None
Esempio n. 6
0
def phone_number(s):
    if v.phone_number(s):
        ret = {}
        p_num = re.sub(r'[^0-9]', '', s)
        ret['area_code'] = p_num[:3]
        ret['number'] = p_num[3:6] + '-' + p_num[6:]
        return ret
    else:
        return None
Esempio n. 7
0
def phone_number(x):
    if val.phone_number(x):
        numbers = re.sub(r'[\D]', '', x)
        return {"area_code" : numbers[:3], "number" : numbers[3:6]+'-'+numbers[6:]}
Esempio n. 8
0
def phone_number(input):
    if v.phone_number(input):
        num = re.sub(r'[^0-9]', '', input)
        return {"area_code" : num[:3], "number" : num[3:6]+'-'+num[6:]}
Esempio n. 9
0
def phone_number(number):
    if v.phone_number(number):
        num = re.sub(r'[^0-9]', '', number)
        return {"area_code": num[:3], "number": num[3:6]+'-'+num[6:]}