简体   繁体   English

HTML:正则表达式可匹配多个示例

[英]HTML: regex expression to match multiple examples

I have an HTML text, where I want to find images and videos. 我有一个HTML文本,我想在其中查找图像和视频。 Found some examples, but can't make it work. 找到了一些示例,但无法使其正常工作。

I have working example for only images: 我只有图像的工作示例:

MatchCollection urls = Regex.Matches(this.item.text, "<img.+?src=[\\\"'](.+?)[\\\"'].*?> );

For both i want to make something like this: 对于两个我想做这样的事情:

MatchCollection urls = Regex.Matches(this.item.text, "<img.+?src=[\\\"'](.+?)[\\\"'].*?> | <iframe .*?/> | <iframe .*?</iframe>");

The last regex found 0 images, where first got 3. 最后一个正则表达式找到了0张图片,其中第一个得到了3张图片。

Try the following: 请尝试以下操作:

(<img.+?src=[\\\"'](.+?)[\\\"'].*?>)|((<iframe.*?\/>)|(<iframe.*?<\/iframe>))

You were missing the parenthesis. 您缺少括号。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM