python 正则表达式检验匹配数字和email

import re
def match_signal(src,dst):
	m=re.match(src,dst)
	if m!=None:
		print('match ok')
		# print(m.group(0))
		# print(m.group(1))
		# print(m.group(2))
		print(m.group())
	else:
		print('fail')
	
src_phone=r'^(\d{3})-(\d{3,8})$'
dst_phone='010-23421'
match_signal(src_phone,dst_phone)

src_email=r'^([0-9a-zA-Z\_]{0,19})@([0-9a-zA-Z]{1,13})\.([com,cn,net]{1,3})$'
dst_email='[email protected]'
match_signal(src_email,dst_email)


你可能感兴趣的:(python,C++)