Products
GG网络技术分享 2025-03-18 16:14 11
把 from obps.a_b_1 ab where ab.conprition = '#conprition#' 这一行中的别名ab取出来,特点是取得值是在obps.表名 的后面(注意表名和别名中间有空格)
import re
_str = "from obps.a_b_1 ab where ab.conprition = '#conprition#'"
_str = re.sub(r'[\\w]* obps.[\\w]* ', "", _str)
_str = re.sub(r' where [\\w. \\'# =]*', "", _str)
print(_str)
正则表达式是建立在字符串的基础上,当需要在字符中使用特殊字符时,python用反斜杠\\转义字符。
如下表:
Demand feedback