小编Vis*_*air的帖子

Python 中不区分大小写的正则表达式

我有以下 Python 正则表达式:

re =re.match(r'.*? from\s+(.*?)(\s.*|$)', q)
Run Code Online (Sandbox Code Playgroud)

这里,q 是这样的查询:

Q1 = u"select * from dlpx_jobs where job_id=\\'531\\';"

Q2 = u"select * FROM dlpx_jobs where job_id=\\'531\\';"
Run Code Online (Sandbox Code Playgroud)

现在,显然,对于 Q1,正则表达式有效,因为“from”在查询中是小写的,但对于 Q2,正则表达式不起作用,因为在 Q2 中,“from”是大写的。

无论“from”是大写还是小写,有什么方法可以使正则表达式同时适用于查询?

python regex python-2.7

4
推荐指数
1
解决办法
1万
查看次数

标签 统计

python ×1

python-2.7 ×1

regex ×1