我想用内部 Package 的html元素替换div中的部分内容。
实际内容:
line 120, col 8: The relative URL 'Helloo' for attribute 'href' in tag 'a' is disallowed. (see undefined)line 136, col 16: The relative URL 'fasdf' for attribute 'href' in tag 'a' is disallowed. (see undefined)line 155, col 12: Missing URL for attribute 'action-xhr' in tag 'form'. (see https://amp.dev/documentation/components/amp-form)
预期输出:
<ul>
<li>The relative URL 'Helloo' for attribute 'href' in tag 'a' is disallowed. (see undefined)</li>
<li>The relative URL 'fasdf' for attribute 'href' in tag 'a' is disallowed. (see undefined)</li>
<li>Missing URL for attribute 'action-xhr' in tag 'form'. (see https://amp.dev/documentation/components/amp-form)</li>
</ul>
- 删除行号信息(行号将动态生成)
- 为每个错误消息创建列表项
1条答案
按热度按时间mrwjdhj31#
它不是很复杂。正则表达式可以帮助你。我用正则表达式来查找每一行的第一行,用**
.split()
**来拆分行