想要替换[说明]和[解释]之间的文本 - Javascript

时间:2015-10-28 09:33:35

标签: javascript

This is your question?

[x] Option A

[ ] Option B

[x] Option C

[x] Option D

[explanation]

<a href="javascript:void(0);" class="X" >View</a>

[explanation]

2 个答案:

答案 0 :(得分:0)

为了在两个其他字符串之间替换字符串(例如,img标签),请使用此...

var output = input.replace(/(?:\r\n|\r|\n)/g, '').replace (/\[explanation\](.*?)\[explanation\]/g, "your string replacement");

答案 1 :(得分:0)

找到解决方案 -

var output = input.replace (/(\[explanation\])[\s\S]+\1/gmi, "[explanation]\n\n"+"My New String"+"\n\n[explanation]" );