private string IdFromEmbed(string input) { foreach (EmbedPattern check in _embedPatterns) { IElementPredicate predicate = new BeginTagPredicate("embed", new RequiredAttribute[] { new RequiredAttribute(check.Attr) }); HtmlExtractor ex = new HtmlExtractor(input); ex = ex.Seek(predicate); if (ex.Success) { BeginTag bt = ex.Element as BeginTag; string srcRef = bt.GetAttributeValue(check.Attr); Match m = Regex.Match(srcRef, check.Pattern, RegexOptions.IgnoreCase); if (m.Success && m.Groups["id"].Success) { return(m.Groups["id"].Value); } } } return(String.Empty); }
public bool MatchesEmbed(string input) { foreach (EmbedPattern check in _embedPatterns) { IElementPredicate predicate = new BeginTagPredicate("embed", new RequiredAttribute[] { new RequiredAttribute(check.Attr) }); HtmlExtractor ex = new HtmlExtractor(input); ex = ex.Seek(predicate); if (ex.Success) { BeginTag bt = ex.Element as BeginTag; string srcRef = bt.GetAttributeValue(check.Attr); if (!Regex.IsMatch(srcRef, check.Pattern, RegexOptions.IgnoreCase)) { return(false); } } else { return(false); //didn't find embed tag with the attr } } return(true); //found all predicates }