예제 #1
0
        public static void Export(string filePath, List <string> head, List <List <string> > rows)
        {
            DirectoryUtils.CreateDirectoryIfNotExists(DirectoryUtils.GetDirectoryPath(filePath));
            FileUtils.DeleteFileIfExists(filePath);

            var builder = new StringBuilder();

            foreach (var name in head)
            {
                builder.Append(name).Append(",");
            }
            builder.Length -= 1;
            builder.Append("\n");

            foreach (var row in rows)
            {
                foreach (var r in row)
                {
                    var value = StringUtils.Replace(r, @"""", @"""""");
                    builder.Append(@"""" + value + @"""").Append(",");
                }
                builder.Length -= 1;
                builder.Append("\n");
            }

            FileUtils.WriteText(filePath, builder.ToString());
        }
예제 #2
0
파일: RegexUtils.cs 프로젝트: apphost/sscms
        public static List <string> GetOriginalImageSrcs(string html)
        {
            html = StringUtils.Replace(html, " data-src=", " src=");
            const string regex = "(img|input)[^><]*\\s+src\\s*=\\s*(?:\"(?<url>[^\"]*)\"|'(?<url>[^']*)'|(?<url>[^>\\s]*))";

            return(GetContents("url", regex, html));
        }