Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/307.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 - Fatal编程技术网

C# 正则表达式无法正确捕获数据

C# 正则表达式无法正确捕获数据,c#,.net,regex,C#,.net,Regex,所以我有下面的代码 var filter = new Regex("(?<=description=\\\")(.+)(?=\\\">)"); return filter.Match(html).ToString(); var filter=newregex((?)”; 返回filter.Match(html.ToString(); 应用正则表达式的HTML数据: <description="This chapter builds upon the

所以我有下面的代码

var filter = new Regex("(?<=description=\\\")(.+)(?=\\\">)");            
return filter.Match(html).ToString();
var filter=newregex((?)”;
返回filter.Match(html.ToString();
应用正则表达式的HTML数据:

<description="This chapter builds upon the information in part 1 ("Introduction to Dynamic Equations")">

结果是:

本章以第1部分(“引言=”“to=”“Dynamic=”“Equations=“”)中的信息为基础

似乎在“(”)之后,正则表达式会尝试创建键值对。我已经尝试了所有的正则表达式选项,但没有一个选项会改变行为。

DEMO: REGEX

<description="(.+)">

描述

<description=" Literal <description="
1st Capturing group (.+) 
    . 1 to infinite times [greedy] Any character (except newline)
"> Literal ">

测试字符串:

<description="This chapter builds upon the information in part 1 ("Introduction to Dynamic Equations")">

  • [14-102]
    本章以第1部分(“动力学方程简介”)中的信息为基础。
  • [anything]
    对\1-\n进行了反向引用,请让我知道您需要的帮助不仅仅限于以下内容“尝试创建键值对”的确切含义是什么?正则表达式似乎在按我的预期工作。请参阅。