How to judge how to pass this verification rule

now there is a requirement that begins with

    130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 145, 147, 150, 151, 152, 153, 155, 156, 157, 158, 159, 173, 175, 176, 177, 178, 180, 181, 182, 183, 184, 184, 185, 186, 187, 188, 189, 166, 198, 199
     

these mobile phone numbers can be verified, how to achieve this method is better? If you use regular, is there a simpler way to write


sincerely advise you not to do this. The valid range of mobile phone number changes every three days. If you need to verify, please use SMS or voice. If you don't need to be strict, just verify the 11 digits at the beginning of 1. Otherwise, the maintainers will keep trampling on it in the future. Because even if the above rules are met, there are still many invalid empty numbers.


def judge(tel):
    begin=('130', '131', '132', '133', '134',
           '135', '136', '137', '138', '139',
           '145', '147', '150', '151', '152',
           '153', '155', '156', '157', '158',
           '159', '173', '175', '176', '177',
           '178', '180', '181', '182', '183',
           '184', '184', '185', '186', '187',
           '188', '189', '166', '198', '199')
    -sharpNone
    if tel:
        -sharptel
        return str(tel).startswith(begin)
    else:
        return False

reference: Python practical techniques part 21: text matching at the beginning and end of a string


import re
pat=re.compile(r'1[3-9][0-9]')
m=re.match(pat,)
if m is not None:
    print('ok')
else:
     print('not phone number')

the first answer is good. If you want to verify strictly, the code is as follows:

import re

m = re.match(r"^1(([358][0-9])|(4[57])|(7[35678])|(9[89])|66)\d{8}$", "15100000000")
if m:
    print(m.group())
-sharp 154,5[012356789]
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1eb75ec-48412.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1eb75ec-48412.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?