我有一堆HTML页面,在这些页面中我想将CSS格式的文本片段转换成标准的HTML标记。e、 g<span class="bold">some text</span>
将变成{
我被困在嵌套的span
片段:
<span class="italic"><span class="bold">XXXXXXXX</span></span>
<span class="italic">some text<span class="bold">nested text<span class="underline">deep nested text</span></span></span>
我想用Python的regex库转换片段。正则表达式搜索-替换上述输入的最佳策略是什么?在
我的解决方案使用lxml和cssselect以及一些Python:
输出:
^{pr2}$NB:这是一个幼稚的解决方案,不能产生正确的输出,因为您必须保留一个打开的标签队列,并在最后关闭它们。在
相关问题 更多 >
编程相关推荐