我有这样的查询:
select * from tdirectories where tdirectories.parent in
(
select max(tdirectories.directoryid) from tdirectories
where tdirectories.ntfsdrivedocuid in
(
select ntfsdrivedocuid from tntfsdrives, tntfsdrivedocu
where tntfsdrivedocu.ntfsdriveid = tntfsdrives.ntfsdriveid and tntfsdrives.hostid in
(
select tdocu.hostid from tdocu, tshares
here tdocu.docuid = tshares.docuid
and tdocu.archiv = 0
)
and tntfsdrivedocu.archiv = 0
)
and tdirectories.pathhash in (select tshares.pathhash from tshares )
)
我想要做的是通过使用RegEx我想找到这个部分:
select max(tdirectories.directoryid)
max
内可以是任何值。我想找到并删除,结果我将
select tdirectories.directoryid
我创建的正则表达式如下所示:
Regex rgx = new Regex("(select\\s.+select)\\smax\\s*\\((?<VAR>[^)]+)\\)");
但这并不能解决我的问题。我错过了什么?
答案 0 :(得分:2)
你可以去(在免费模式下):
select # select literally
\ # a space
max # max literally
\(([^)]+)\) # capture anything inside the parentheses
并使用第一组($1
),请参阅a demo on regex101.com。