首先,mysql 模糊匹配使用like语句,通配符有:%,_(下划线)
%的作用:表示任何字符出现任意次数(即可以匹配任意字符0次或无数次)
_(下划线)作用:只能匹配单个字符。
01.例:我要模糊查询名字是张开头的,且名字是2个字的所有用户;
使用_(下划线)匹配
sql语句为:select * from users where name like ‘张_’;
结果:
+—-+——–+———+—————+——-+
| id | name | role_id | password_hash
首先来个简单的例子,利用Python实现匹配163邮箱的代码:
#-*- coding:utf-8 -*-
__author__ = '杨鑫'
import re
text = input("Please input your Email address:\n"):
if re.match(r'[0-9a-zA-Z_]{0,19}163.com',text):
print('Email address is Right!')
else:
print('Please reset your