Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/340.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中提取IMGSRC_C#_Html_Regex_Image_Extract - Fatal编程技术网

C# 正则表达式-从HTML中提取IMGSRC

C# 正则表达式-从HTML中提取IMGSRC,c#,html,regex,image,extract,C#,Html,Regex,Image,Extract,我知道我不应该在HTML中使用正则表达式。 我想从HTML文件中提取图像源,示例如下: 可能是这样的: <img src = cid:header width="700" height="93" alt="Logo" /> <img src= cid:header width="700" height="93" alt="Logo" /> <img src =cid:header width="700" height="93" alt="Logo" /> &l

我知道我不应该在HTML中使用正则表达式。 我想从HTML文件中提取图像源,示例如下:

可能是这样的:

<img src = cid:header width="700" height="93" alt="Logo" />
<img src= cid:header width="700" height="93" alt="Logo" />
<img src =cid:header width="700" height="93" alt="Logo" />
<img src=cid:header width="700" height="93" alt="Logo" />

在每种情况下,我都希望得到“cid:header”作为结果。

因为我的正则表达式知识基本上是零,所以我求助于你们。 我需要一个在“src”或“=”字符后接受空格的模式

src[mightBeSpace]=[mightBeSpace]cid:[mustNotBeSpace]

谢谢大家!

^$
^<img src\s?=\s?([^\s]+).*/>$
正则表达式中的“可能是空格”是
\s*
,而“必须是无空格”则翻译为
\s+


使用这些信息,您应该能够构建正则表达式。如果不能,请显示您已尝试的内容。

我按原样提供此内容,以匹配仅包含您提供内容的一行txt。请注意(正如@Kolink所指出的),RegEx在匹配HTMLsrc\s?=\s?([^\s]+)方面非常糟糕。这是我唯一需要的一方,谢谢!如果您认为答案充分回答了您的问题,请将其标记为答案。我会尽快回答您的问题。