Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/regex/20.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# 正则表达式来获取NVP';s_C#_Regex - Fatal编程技术网

C# 正则表达式来获取NVP';s

C# 正则表达式来获取NVP';s,c#,regex,C#,Regex,是否有一个正则表达式可以从下面的字符串中获得一个名称-值对,如下所示: 状态代码=179640000 新批准=179640002 发件人: &$filter=statuscode/Value eq 179640000和新批准的/Value eq 179640000^&filter=({[0-9a-zA-Z]+}/Value eq{[0-9a-zA-Z]+})(和)?)$ 我认为这可以作为一个通用模板。您需要稍微修改一下语法,才能使用所使用的任何正则表达式引擎。示例程序: public s

是否有一个正则表达式可以从下面的字符串中获得一个名称-值对,如下所示:

状态代码=179640000
新批准=179640002

发件人:

&$filter=statuscode/Value eq 179640000和新批准的/Value eq 179640000
^&filter=({[0-9a-zA-Z]+}/Value eq{[0-9a-zA-Z]+})(和)?)$

我认为这可以作为一个通用模板。您需要稍微修改一下语法,才能使用所使用的任何正则表达式引擎。

示例程序:

    public static void Main()
    {
        string src = "&$filter=statuscode/Value eq 179640000 and new_Approved/Value eq 179640000";
        Regex regex = new Regex(@"(\w*)/Value eq (\w*)");

        foreach (Match m in regex.Matches(src))
        {
            foreach (Group g in m.Groups)
            {
                Console.WriteLine(g.Value);
            }
        }
    }
给出以下输出

statuscode/Value eq 179640000
statuscode
179640000
new_Approved/Value eq 179640000
new_Approved
179640000
Press any key to continue . . .
在一场比赛中,你为每组准备的是:

  • 比赛本身
  • 值的名称
  • 价值本身
  • 它假设所有的名称和值都是字母数字和
    '.
    ,还假设源字符串没有其他曲线球

    看。同样的事情,除了逗号之外,您的对之间用
    |