代码是下面这样的<p>
<embed src="/editor/kindeditor/attached/media/20130626/20130626065054_3546.avi" type="video/x-ms-asf-plugin" width="550" height="400" autostart="false" loop="true" />
</p>
<p>
addw
</p>
<p>
<embed src="/editor/kindeditor/attached/media/20130626/20130626084219_0577.avi" type="video/x-ms-asf-plugin" width="550" height="400" autostart="true" loop="true" />
</p>
我想取出红色的内容外层标签用flash播放器替代。蓝色内容不固定。
逻辑不是很会。C#正则
<embed src="/editor/kindeditor/attached/media/20130626/20130626065054_3546.avi" type="video/x-ms-asf-plugin" width="550" height="400" autostart="false" loop="true" />
</p>
<p>
addw
</p>
<p>
<embed src="/editor/kindeditor/attached/media/20130626/20130626084219_0577.avi" type="video/x-ms-asf-plugin" width="550" height="400" autostart="true" loop="true" />
</p>
我想取出红色的内容外层标签用flash播放器替代。蓝色内容不固定。
逻辑不是很会。C#正则
解决方案 »
- asp.net 如何实现将 html代码转成pdf文件
- 关于asp.net模板
- 100分调查:有多少人会做服务器的安全?
- 求一正则 替换空格
- 好久不来,问个服务器虚拟目录的问题。顺便散分.....................
- 为什么我编写好的程序,在本机上用localhost访问可以,而ip访问不可以,而且别的电脑访问也不行
- 那位兄弟有空帮我将段C#转为VB.net
- 谁能帮我找到这个模块???
- 谁有html编辑器的控件
- 在微信中显示的MVC网页在添加视图时是选择ASPX(C#),还是选择Razor(CSHTML) ?
- asp.net怎么实现数据库中同一表的两数相加
- asp.net 使用js出错。
string tempStr = File.ReadAllText(@"C:\Users\myx\Desktop\Test.txt", Encoding.GetEncoding("GB2312"));//读取txt string src="/editor/kindeditor/attached/media/20130626/20130626065054_3546.avi";
string pattern = @"(?i)<embed[^>]*?src=(['""]?)"+src+@"\1[^>]*?>";
tempStr = Regex.Replace(tempStr,pattern,"替换内容");
flashMask = "<object classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" codebase=\"...\"><param name="movie" value=\"$1\" /><param name=\"quality\" value=\"high\"/></object>";
tempStr = Regex.Replace(html, regex, flashMask);
flashMask = "<object classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" codebase=\"...\"><param name="movie" value=\"$2\" /><param name=\"quality\" value=\"high\"/></object>";
result= Regex.Replace(html, regex, flashMask);
<param name="movie" value="FLVPlayer_Progressive.swf" />
<param name="salign" value="lt" />
<param name="quality" value="high" />
<param name="scale" value="noscale" />
<param name="FlashVars" value="&MM_ComponentVersion=1&skinName=Halo_Skin_3&streamName=7&autoPlay=true&autoRewind=false" />
<embed src="替换掉的src" flashvars="&MM_ComponentVersion=1&skinName=Halo_Skin_3&streamName=7&autoPlay=true&autoRewind=false" quality="high" scale="noscale" width="722" height="551" name="FLVPlayer" salign="LT" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />
</object>
string pattern = @"(?i)<embed[^>]*?src=(['""]?)([^'""]*?)\1[^>]*?>";
tempStr = Regex.Replace(tempStr, pattern, a => {
string src = a.Groups[2].Value;
string result = string.Empty+src;//根据src拼接结果
return result;
});
string html = @"<p>
<embed src=""/editor/kindeditor/attached/media/20130626/20130626065054_3546.avi"" type=""video/x-ms-asf-plugin"" width=""550"" height=""400"" autostart=""false"" loop=""true"" />
</p>
<p>
addw
</p>
<p>
<embed src=""/editor/kindeditor/attached/media/20130626/20130626084219_0577.avi"" type=""video/x-ms-asf-plugin"" width=""550"" height=""400"" autostart=""true"" loop=""true"" />
</p>";
string regex = @"(?is)<embed\s*[^>]*?src=(['""]?)([^'""]+)\1[^>]*?(width=\1\d+\1)\s*(height=\1\d+\1)\s*autostart=\1(?:true|false)\1[^>]*?>",
flashMask = "<object classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" codebase=\"...\"><param name=\"movie\" $3 $4 value=\"$2\" /><param name=\"quality\" value=\"high\"/></object>";
html = Regex.Replace(html, regex, flashMask);