Generate_Cnblogs_Articles_To_Markdown_Files.CnblogsHelper.ProcessArticleImage C# (CSharp) Method

ProcessArticleImage() private static method

private static ProcessArticleImage ( string articleContent, string imagePrefixUrl = "" ) : string
articleContent string
imagePrefixUrl string
return string
        private static string ProcessArticleImage(string articleContent, string imagePrefixUrl = "")
        {
            var regex = new Regex(@"<img\s+src=""(?<src>.*?)""", RegexOptions.Singleline | RegexOptions.Multiline);
            var matches = regex.Matches(articleContent);
            var preImagePath = "";
            foreach (Match match in matches)
            {
                var imagePath = match.Groups["src"].ToString();
                var imageName = imagePath.Substring(imagePath.LastIndexOf("/") + 1);
                if (string.IsNullOrEmpty(preImagePath))
                {
                    preImagePath = imagePath.Substring(0, imagePath.LastIndexOf("/") + 1);
                }
                NetworkHelper.SavePhotoFromUrl(Application.StartupPath + "\\images\\" + imageName, imagePath);
            }
            if (matches.Count > 0 && !string.IsNullOrEmpty(imagePrefixUrl))
            {
                return articleContent.Replace(preImagePath, imagePrefixUrl); //自己的图床前缀
            }
            return articleContent;
        }