要求:var str="<p><h1>the emulsion janus</h1> simulate of cu<sub>2</sub>CO</p>"想分離成json格式:
str_json={"h1":"the emulsion janus","text1":"simulate of cu","sub":2,"text2":"CO"}補充:分隔符只有<sub></sub>,<sup></sup>,<h1></h1>,<p></p>。如何用正則表達(dá)式分離?或者先計算indexof,然后用普通的字符串分割?因為要計算大量的,所以要考慮效率。
js中分離字符串的問題?
慕森王
2018-10-19 14:11:10