SQL中使用python中的正则表达式

时间:2016-06-16 14:17:50

标签: python sql google-bigquery

我在python中运行此查询。我在正则表达式部分中得到错误“无效的字符串文字”。我知道这个正则表达式,不知道这里缺少什么语法。任何帮助将不胜感激。

import pandas as pd
import numpy as np
import datetime
from time import gmtime, strftime
import smtplib
import sys
from IPython.core.display import HTML

PROJECT = 'server'

queryString = '''

SELECT 
  mn as mName,
  dt as DateTime,
  ip as LocalIPAddress,
  REGEXP_EXTRACT(path, 'ActName:([\s\S\w\W]*?)ActDomain:') AS ActName,
FROM Agent.Logs

'''

1 个答案:

答案 0 :(得分:1)

您错过了r

REGEXP_EXTRACT(path, r'ActName:([\s\S\w\W]*?)ActDomain:') AS ActName