使用带 Impala SQL 的正则表达式选择最后一个 \\ 之后的字符串
Selecting string after the last \\ using regex with Impala SQL
我有一个数据集,其中有一列包含进程和路径。我正在尝试将正则表达式与 Impala 结合使用来剥离可执行文件。数据集如下所示:
C:\Windows\System32\svchost.exe
C:\Windows\System32\conhost.exe
C:\Windows\System32\net1.exe
C:\Windows\System32\schtasks.exe
C:\Program Files (x86)\Citrix\ICA Client\SelfServicePlugin\SelfService.exe
C:\Windows\System32\backgroundTaskHost.exe
C:\Windows\System32\net.exe
C:\Windows\System32\conhost.exe
C:\Program Files (x86)\Wireless AutoSwitch\wrlssw.exe
期望的输出:
svchost.exe
conhost.exe
net1.exe
schtasks.exe
SelfService.exe
backgroundTaskHost.exe
net.exe
conhost.exe
wrlssw.exe
我已经尝试了很多查询,例如下面两个,但一直 运行 出错
select regexp_extract(w.destinationprocessname, '([^\]+)$')
from winworkstations_realtime w
where w.externalid = '4688'
limit 10
错误:
AnalysisException: No matching function with signature: regexp_replace(STRING, STRING).
select regexp_extract(w.destinationprocessname, '\(?:.(?!\))+$',0)
from winworkstations_realtime w
where w.externalid = '4688'
limit 10
错误:
Could not compile regexp pattern: \(?:.(?!\))+$ Error: invalid perl operator: (?!
向精通 impala 或正则表达式的人寻求一些指导。
不是正则表达式专家,我相信有更好的方法,但这确实有效
select regexp_replace(regexp_extract("C:\\Windows\\System32\\svchost.exe", ".+(\\.+)$", 1), "\\", "");
我有一个数据集,其中有一列包含进程和路径。我正在尝试将正则表达式与 Impala 结合使用来剥离可执行文件。数据集如下所示:
C:\Windows\System32\svchost.exe
C:\Windows\System32\conhost.exe
C:\Windows\System32\net1.exe
C:\Windows\System32\schtasks.exe
C:\Program Files (x86)\Citrix\ICA Client\SelfServicePlugin\SelfService.exe
C:\Windows\System32\backgroundTaskHost.exe
C:\Windows\System32\net.exe
C:\Windows\System32\conhost.exe
C:\Program Files (x86)\Wireless AutoSwitch\wrlssw.exe
期望的输出:
svchost.exe
conhost.exe
net1.exe
schtasks.exe
SelfService.exe
backgroundTaskHost.exe
net.exe
conhost.exe
wrlssw.exe
我已经尝试了很多查询,例如下面两个,但一直 运行 出错
select regexp_extract(w.destinationprocessname, '([^\]+)$')
from winworkstations_realtime w
where w.externalid = '4688'
limit 10
错误:
AnalysisException: No matching function with signature: regexp_replace(STRING, STRING).
select regexp_extract(w.destinationprocessname, '\(?:.(?!\))+$',0)
from winworkstations_realtime w
where w.externalid = '4688'
limit 10
错误:
Could not compile regexp pattern: \(?:.(?!\))+$ Error: invalid perl operator: (?!
向精通 impala 或正则表达式的人寻求一些指导。
不是正则表达式专家,我相信有更好的方法,但这确实有效
select regexp_replace(regexp_extract("C:\\Windows\\System32\\svchost.exe", ".+(\\.+)$", 1), "\\", "");