完整的HTML标签javascript

时间:2015-09-14 13:02:33

标签: javascript html regex

我有3个变量。

before = "<p>i am a p</p>some text <a href="">"
middle = "URL</a>another text<div>i am after div";
after = "</div>last text"

我想要的只是在“中间”(从之前或之后)找到缺失标签而只是那个。

例如,我的中间结果应该是我:

before = "<p>i am a p</p>some text"
middle = " <a href="">URL</a>another text<div>i am after div</div>";
after = "last text"

我该怎么做?

1 个答案:

答案 0 :(得分:0)

你需要告诉你链接的引用,如:

before = "<p>i am a p</p>some text"
middle = " <a href=\"\">URL</a>another text<div>i am after div</div>";
after = "last text"