Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/325.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# 使用Linq to xml从xml文档的值字段返回子字符串_C#_Xml_Linq_Linq To Xml - Fatal编程技术网

C# 使用Linq to xml从xml文档的值字段返回子字符串

C# 使用Linq to xml从xml文档的值字段返回子字符串,c#,xml,linq,linq-to-xml,C#,Xml,Linq,Linq To Xml,XML字段如下所示: <Element> 0 (0)</Element> 以及讨论中的Linq到XML: variableName = e.Descendants().Where(i => regularExpression.IsMatch(i.Value.ToString())).Select(j => regularExpression.Match(j.Value.ToString()).Groups[1].Value.ToString()).ToLi

XML字段如下所示:

<Element> 0 (0)</Element>
以及讨论中的Linq到XML:

variableName =  e.Descendants().Where(i => regularExpression.IsMatch(i.Value.ToString())).Select(j => regularExpression.Match(j.Value.ToString()).Groups[1].Value.ToString()).ToList()
但是,当我尝试打印此值时,它不会打印任何内容


我在这里做错了什么?

您的正则表达式应该使用
'\s'
而不是
'

Regex regEx2 = new Regex(@"(\d+)\s\((\d+)\)", RegexOptions.IgnorePatternWhitespace);
Regex regEx2 = new Regex(@"(\d+)\s\((\d+)\)", RegexOptions.IgnorePatternWhitespace);