嘿,我有一些格式如下的文本:
[quote]foo text[/quote]
我想把它改成这样:
<div class="quote-text">foo text</div>
如何用 JS 做到这一点?
我正在使用 jQuery。
最佳答案
应该执行以下操作:
string.replace(/\[quote\](.*?)\[\/quote\]/g, "<div class=\"quote-text\">".$1."</div>");
关于javascript - 使用 [quote]foo text[/quote] 抓取文本并用 JS 将其替换为 <div class ="quote-text">foo text</div>,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1377266/