Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/323.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/.net/23.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 用其他值替换正则表达式匹配_C#_.net_Regex_Vb.net - Fatal编程技术网

C# 用其他值替换正则表达式匹配

C# 用其他值替换正则表达式匹配,c#,.net,regex,vb.net,C#,.net,Regex,Vb.net,我有这样一个问题: select * from tdirectories where tdirectories.parent in ( select max(tdirectories.directoryid) from tdirectories where tdirectories.ntfsdrivedocuid in ( select ntfsdrivedocuid from tntfsdrives, tntfsdrivedocu

我有这样一个问题:

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 rgx = new Regex("(select\\s.+select)\\smax\\s*\\((?<VAR>[^)]+)\\)");
我想做的是,通过使用RegEx,我想找到以下部分:

select max(tdirectories.directoryid) 
max
中可以是任何值。我想找到它,并删除,因此我将

select tdirectories.directoryid
我创建的正则表达式如下所示:

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 rgx = new Regex("(select\\s.+select)\\smax\\s*\\((?<VAR>[^)]+)\\)");
Regex rgx=new Regex(“(select\\s.+select)\\smax\\s*\\((?[^)]+)\\”;
但这并不能解决我的问题。我错过了什么?

您可以选择(在免费模式下):


并使用第一个组(
$1
),请参阅。

外部查询是否总是“选择*”?是的,它是。我想选择所有的情况下,选择后有最大值,并删除最大值我想捕获组应该为这项工作。。。试一试:在给定的查询文本中,选择\s*(max([a-zA-Z0-9\.\uz]+),并将组{1}替换为组{2}\塔克斯需要帮助。