Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/313.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中使用regex.Matches#_C#_Regex - Fatal编程技术网

C# 如何在c中使用regex.Matches#

C# 如何在c中使用regex.Matches#,c#,regex,C#,Regex,如何使用regex.Matches 输入字符串 string strQuery = "BO_WEEKOFF_MASTER.year, week_off_day=case when "+ "BO_WEEKOFF_MASTER.week_off_day ='1' then 'Sunday' "+ "when BO_WEEKOFF_MASTER.week_off_day ='2' then 'Monday' "+

如何使用regex.Matches

输入字符串

  string strQuery = "BO_WEEKOFF_MASTER.year, week_off_day=case when "+
                    "BO_WEEKOFF_MASTER.week_off_day ='1' then 'Sunday' "+ 
                    "when  BO_WEEKOFF_MASTER.week_off_day ='2' then 'Monday' "+
                    "when  BO_WEEKOFF_MASTER.week_off_day ='3' then 'Tuesday' "+
                    "when  BO_WEEKOFF_MASTER.week_off_day ='4' then 'Wednesday' "+
                    "when  BO_WEEKOFF_MASTER.week_off_day ='5' then 'Thursday' "+
                    "when  BO_WEEKOFF_MASTER.week_off_day ='6' then 'Friday' "+
                    "when  BO_WEEKOFF_MASTER.week_off_day ='7' then 'Saturday' "+
                    "else '' end,"+
                    "BO_WEEKOFF_MASTER.year, week_off_day=case when "+
                    "BO_WEEKOFF_MASTER.week_off_day ='1' then 'Sunday' "+                   
                    "when  BO_WEEKOFF_MASTER.week_off_day ='2' then 'Monday' "+
                    "when  BO_WEEKOFF_MASTER.week_off_day ='3' then 'Tuesday' "+ 
                    "when  BO_WEEKOFF_MASTER.week_off_day ='4' then 'Wednesday' "+  
                    "when  BO_WEEKOFF_MASTER.week_off_day ='5' then 'Thursday' "+ 
                    "when  BO_WEEKOFF_MASTER.week_off_day ='6' then 'Friday' "+ 
                    "when  BO_WEEKOFF_MASTER.week_off_day ='7' then 'Saturday' "+
                    "else '' end,";
我的模式是

MatchCollection words = Regex.Matches(strQuery, @"(?i)?<firstMatch>.*,)  (?<secondMatch>[^=]*)=case(?<thirdMatch>.*end\b)");
    foreach (Match word in words)
    {
        strQuery = Regex.Replace(word , @"....", @" ... ", RegexOptions.IgnoreCase);

    }
我犯了错误,
谢谢您

您需要使用捕获组

Regex.Replace(word , @"(\w+)=(case.*?\bend\b)", @"$2 ""$1""", RegexOptions.IgnoreCase);

请重新设置问题的格式。你想达到什么目标?稍微解释一下。我正在将SQL查询转换为Oracle查询…您要替换哪一部分?SQL“word=case….end”转换为Oracle“case….end word”
Regex.Replace(word , @"(\w+)=(case.*?\bend\b)", @"$2 ""$1""", RegexOptions.IgnoreCase);