Python--每日正则(四)

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/MR_HJY/article/details/81750646
import re

line = '111songqihu a'
# \w  匹配字母数字及下划线
# match_res = re.match('\w{2,5}', line)
# if match_res:
#     print(match_res)
#     print(match_res.group(0)) #111so
#     print('ojbk')
# else:
#     print('不欧克')

# \d 匹配任意数字
# match_res = re.match('\d{2,5}', line)
# if match_res:
#     print(match_res)
#     print(match_res.group(0)) #111
#     print('ojbk')
# else:
#     print('不欧克')


# \s 空白
# match_res = re.search('\s', line)
# if match_res:
#     print(match_res)
#     print(match_res.group(0))
#     print('ojbk')
# else:
#     print('不欧克')

猜你喜欢

转载自blog.csdn.net/MR_HJY/article/details/81750646
今日推荐