删除 SGML 中的多个标签

发布于 2024-09-18 05:44:26 字数 218 浏览 13 评论 0原文

我有一个 sgml 文件,就像

<p><p><data>sdlksdskdmskdmsamdakmdksam<p></data>...

我的问题是如何删除一个标签

并保持另一个完整......哪个正则表达式是可以的......

i have a sgml file like

<p><p><data>sdlksdskdmskdmsamdakmdksam<p></data>...

my question is how to remove one tag <p> and keep another one intact ...which regular expression would be siutable......

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

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

发布评论

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

评论(1

心的位置 2024-09-25 05:44:26

如果您的 SGML 可以作为 XML 进行处理,那么 XProc 是一个很好的技术类似的事情,只需一个步骤,例如:(

<p:unwrap match="p[parent::p]"/>

假设您想要删除所有自嵌套的 p 元素,直到 p 永远不会自行包装)。

您绝对不想想要使用正则表达式处理 SGML/XML,除非您 100% 确定您将处理具有某种明确指定的词汇形式的子集。例如,考虑一下如何使用正则表达式处理带有注释的内容:

<p><!-- <p> commented out--><foo><p/><p/></foo></p>

!!

If your SGML is such it can be processed as XML, then XProc is a good technology for this kind of thing, with a single step such as:

<p:unwrap match="p[parent::p]"/>

(Assuming you want to remove all self-nested p elements until p never wraps itself).

You definitely do not want to process SGML/XML with regexps unless you are 100% certain you will be dealing with a subset which has a certain well-specified lexical form. Think for example how you'd process stuff with comments using a regexp:

<p><!-- <p> commented out--><foo><p/><p/></foo></p>

!!

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