/// <summary>
 /// using a regular expression, find all of the href or urls 
 /// in the content of the page 
 /// </summary>
 /// <param name="content"></param>
 private void GetAllImagesUrls( string content )
 {
     //regular expression Responsible for finding all images on html document.
     string Pattern = @"(http://)[A-Za-z0-9\-\.]+\.[A-Za-z]{2,3}(:[a-zA-Z0-9]*)?/?([a-zA-Z0-9\-\._\?\,\'/\\\+&amp;%\$#\=~])*[^\.\,\)\(\s].(jpg|.png|.gif|.tiff)";
     Regex Regex = new Regex(Pattern, RegexOptions.Compiled | RegexOptions.IgnoreCase);
     Matches = Regex.Matches(content);
     ListOfDistinctMatches = Matches.Cast<Match>().Select(m => m.Value).Distinct().ToList();
 }
Пример #2
0
        private static string formatMsoftMatches(Msoft.MatchCollection matches)
        {
            Msoft.Match[] matchArr = matches.Cast <Msoft.Match>().ToArray();

            return(string.Format("{0} matches: [{1}]",
                                 matchArr.Length,
                                 matchArr.Select(m => formatMsoftMatch(m))
                                 .JoinStrings()));
        }
Пример #3
0
 public static Match2[] CreateMatches(Msoft.MatchCollection msoftMatches)
 {
     return(msoftMatches.Cast <Msoft.Match>()
            .Select(m => CreateMatch(m))
            .ToArray());
 }
Пример #4
0
        public static List<string> PreProcessPacket(MatchCollection matches)
        {
            var list = (matches.Cast<Match>().Select(line => line.Value.Trim())).ToList();

            return list;
        }
Пример #5
0
 /// <summary>
 /// Returns the input typed as a generic IEnumerable of the matches
 /// </summary>
 /// <param name="mc"></param>
 /// <returns></returns>
 public static IEnumerable <System.Text.RegularExpressions.Match> AsEnumerable(
     this System.Text.RegularExpressions.MatchCollection mc)
 {
     return(mc.Cast <Match>());
 }