Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/335.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# 使用正则表达式匹配HTML内部文本中的单词组合_C#_Regex - Fatal编程技术网

C# 使用正则表达式匹配HTML内部文本中的单词组合

C# 使用正则表达式匹配HTML内部文本中的单词组合,c#,regex,C#,Regex,我正在尝试使用C#匹配HTML文件的标记内部文本中的内容 我正在使用以下代码执行此操作: matchValue = "^.*" + TDInnerText + ".*$"; match = Regex.Match(innerText, @matchValue, RegexOptions.Multiline); if (match.Success) { // Do Something } 调试程序时,变量下的值如下所示: innerText = "\r\n\r\n\r\n\r\n \r

我正在尝试使用C#匹配HTML文件的
标记内部文本中的内容

我正在使用以下代码执行此操作:

matchValue = "^.*" + TDInnerText + ".*$";

match = Regex.Match(innerText, @matchValue, RegexOptions.Multiline);
if (match.Success) {
    // Do Something
}
调试程序时,变量下的值如下所示:

innerText = "\r\n\r\n\r\n\r\n \r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n Our industry aligned technology architects provide solutions that work and that add exceptional value. We understand business intricacy; we know our technology and we know how to bring this knowledge and understanding together to provide end-to end domain specific intuitive strategic solutions.                   \r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n"

matchValue = "^.*Our industry aligned technology.*$"
我在在线正则表达式计算器中检查了这些值,它检测到一个匹配项。 但是,对于
match.Success
,程序返回
false


我在这里遗漏了什么吗?

这对我很有用:@minitech:当你编辑他的帖子时,你将他的
matchValue
matchValue=“^.我们与行业一致的技术。$”
更改为
matchValue=“^.*我们与行业一致的技术。*$”
,这也会匹配,但是这样就否定了问题/答案。@Aren:这是因为代码没有格式化。星号在那里,他们只是把代码改成斜体。所以当我格式化它们时,它们回来了。要了解这一点,请使用修订版#1上的“源代码”链接。啊,很好的回答,那么我的答案是没有意义的,因为我在阅读时没有*'sHow is innerText defined?另一方面,为什么在第二条语句中在matchValue之前使用“@”?