时间:2023-11-25 01:30:01 | 来源:网站运营
时间:2023-11-25 01:30:01 来源:网站运营
有什么免费的网页开发与代码编辑软件?:推荐工具:.NET Fiddleusing System;public class Program{ public static void Main() { string img = "i<img style='aaa' />j<Img style='bbb' />k<img style='ccc' ></img>"; Console.WriteLine(ReplacehtmlBody(img)); Console.WriteLine(ReplacehtmlBody2(img)); } public static string ReplaceRegex(string content, string regParen, string replyContent) { string strOutput = System.Text.RegularExpressions.Regex.Replace(content, regParen, replyContent); return strOutput; } public static string ReplacehtmlBody(string htmlBody) { if (string.IsNullOrWhiteSpace(htmlBody)) { return htmlBody; } return ReplaceRegex(htmlBody, "(i?)(//<img.*?style=['/"])([^//>]+//>)", "$2max-width: 80% !important;$3"); } public static string ReplacehtmlBody2(string htmlBody) { if (string.IsNullOrWhiteSpace(htmlBody)) { return htmlBody; } var reg = new System.Text.RegularExpressions.Regex("(//<img.*?style=['/"])([^//>]+//>)", System.Text.RegularExpressions.RegexOptions.IgnoreCase); return reg.Replace(htmlBody, "$1max-width: 80% !important;$2"); }}
<img style='max-width: 80% !important;aaa' />j<Img style='bbb' />k<img style='max-width: 80% !important;ccc' ></img>i<img style='max-width: 80% !important;aaa' />j<Img style='max-width: 80% !important;bbb' />k<img style='max-width: 80% !important;ccc' ></img>
地址:关键词:编辑,免费