コード例 #1
0
        public string Parse(PostFilterContext context)
        {
            var msg = context.HtmlToParse;
            var regex =
                @"((www\.|(http|https|ftp|news|file)+\:\/\/)[&#95;.a-z0-9-]+\.[a-z0-9\/&#95;:@=.+?,##%&~-]*[^.|\'|\# |!|\(|?|,|\s|>|<|;|\)])";
            var r = new Regex(regex, RegexOptions.IgnoreCase);
            return r.Replace(msg, match =>
            {
                if (msg[match.Index - 1] == '"')
                    return match.Value;

                return string.Format(@"<a href=""{0}"">{0}", match.Value);
            }).Replace("href=\"www", "href=\"http://www");
        }
コード例 #2
0
 public string Parse(PostFilterContext context)
 {
     return Regex.Replace(context.HtmlToParse, @"<h(?<number>[1-6])>(?<innerText>[^<]*)</h[1-6]>", FormatHeadings);
 }