这个字符串格式有什么问题吗?

发布于 2024-09-16 08:22:18 字数 898 浏览 2 评论 0原文

我想知道是否有人知道这个 html 字符串代码是怎么回事:

    <object height=\\\"38\" + \"5\\\" width=\\\"64\" + \"0\\\" classid=\\\"clsid:D27CDB6E-
AE6D-11cf-96B8-444553540000\\\" id=\\\"movie_player\\\" ><param name=\\\"movie\\\" 
value=\\\"http:\\/\\/s.ytimg.com\\/yt\\/swf\\/watch_as3-vfl186120.swf\\\"><param 
name=\\\"flashvars\\\" value=\\\"...." allowscriptaccess=\\\"always\\\" 
allowfullscreen=\\\"true\\\" bgcolor=\\\"#000000\\\" \\/>

它看起来很可怕......它嵌入在 JavaScript 函数中,稍后将呈现到页面上。谁能告诉我如何使用 Html Agility Pack 或可能的 RegEx 来清理它,尽管它看起来很乱!

重要的方面是让 height=\\\"38\" + \"5\\\" 变为 height="385" 等。我可以摆脱过度削减没有问题。

非常感谢任何指导。

编辑:最后,这就是我用来完成标签的内容,

        objectNodeFormat.Replace(@"\", "");
        objectNodeFormat.Replace(@" + ", "");
        objectNodeFormat.Replace(@"""""", "");

再次感谢。

I was wondering if anyone knows what's up with this html string code:

    <object height=\\\"38\" + \"5\\\" width=\\\"64\" + \"0\\\" classid=\\\"clsid:D27CDB6E-
AE6D-11cf-96B8-444553540000\\\" id=\\\"movie_player\\\" ><param name=\\\"movie\\\" 
value=\\\"http:\\/\\/s.ytimg.com\\/yt\\/swf\\/watch_as3-vfl186120.swf\\\"><param 
name=\\\"flashvars\\\" value=\\\"...." allowscriptaccess=\\\"always\\\" 
allowfullscreen=\\\"true\\\" bgcolor=\\\"#000000\\\" \\/>

It looks horrible... It is embedded in a JavaScript function, to later be rendered to the page. Can anyone tell me how I can clean it using say Html Agility Pack or possibly RegEx although it looks messy!

Important aspect is getting the height=\\\"38\" + \"5\\\" to become height="385" etc. I can get rid of the excesses slashes no problem.

Really appreciate any guidance.

Edit: in the end this is what I used to complete the tags

        objectNodeFormat.Replace(@"\", "");
        objectNodeFormat.Replace(@" + ", "");
        objectNodeFormat.Replace(@"""""", "");

Thanks again.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

长梦不多时 2024-09-23 08:22:18

看起来双反斜杠是为了转义斜杠,第三个反斜杠是为了转义引号......哇!它看起来确实很乱......比如说......将所有字符串填充到 StringBuilder 中并使用 StringBuilder 对象的 Remove Replace 方法来删​​除所有这些反斜杠......

StringBuilder sbRemove = new StringBuilder();
sbRemove.Append(@"<object height=\\\"38\" + \"5\\\" width=\\\"64\" + \"0\\\" classid=\\\"clsid:D27CDB6E-
AE6D-11cf-96B8-444553540000\\\" id=\\\"movie_player\\\" ><param name=\\\"movie\\\" 
value=\\\"http:\\/\\/s.ytimg.com\\/yt\\/swf\\/watch_as3-vfl186120.swf\\\"><param 
name=\\\"flashvars\\\" value=\\\"...." allowscriptaccess=\\\"always\\\" 
allowfullscreen=\\\"true\\\" bgcolor=\\\"#000000\\\" \\/>");
sbRemove.Replace(@"\\\", "");
sbRemove.Replace(@"\"", "");

编辑:将其更改为替换 - mea culpa

Looks like the double backslash is to escape the slash and the third backslash to escape the quote... wow! it does look messy.... say... stuff all that string into a StringBuilder and use the Remove Replace method of the StringBuilder object to strip out all those backslashes...

StringBuilder sbRemove = new StringBuilder();
sbRemove.Append(@"<object height=\\\"38\" + \"5\\\" width=\\\"64\" + \"0\\\" classid=\\\"clsid:D27CDB6E-
AE6D-11cf-96B8-444553540000\\\" id=\\\"movie_player\\\" ><param name=\\\"movie\\\" 
value=\\\"http:\\/\\/s.ytimg.com\\/yt\\/swf\\/watch_as3-vfl186120.swf\\\"><param 
name=\\\"flashvars\\\" value=\\\"...." allowscriptaccess=\\\"always\\\" 
allowfullscreen=\\\"true\\\" bgcolor=\\\"#000000\\\" \\/>");
sbRemove.Replace(@"\\\", "");
sbRemove.Replace(@"\"", "");

Edit: Changed it to Replace - mea culpa

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文