Files
EmbedImageMiddleware/src/EmbedImagesMiddlewear/BclExtensions.cs
Tommy Parnell 09cd485ab9 init
2016-07-23 21:06:36 -04:00

22 lines
697 B
C#

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
namespace EmbedImagesMiddlewear
{
public static class BclExtensions
{
private static Regex regexImgSrc = new Regex(@"<img[^>]*?src\s*=\s*[""']?([^'"" >]+?)[ '""][^>]*?>", RegexOptions.Compiled | RegexOptions.IgnoreCase | RegexOptions.Singleline);
public static IEnumerable<string> ToImageLinks(this string htmlSource)
{
var matchesImgSrc = regexImgSrc.Matches(htmlSource);
foreach (Match m in matchesImgSrc)
{
yield return m.Groups[1].Value;
}
}
}
}