如何删除方括号内的任何字符串

How to remove any string inside square brackets

本文关键字:任何 字符串 方括号 何删除 删除      更新时间:2023-09-26

我从http://ar.wikipedia.org复制了一些段落它包含了许多[15],[89],[等等]我想用JavaScript或jQuery自动删除[]和里面的任何东西

试试这个正则表达式。

test = "[5] new value";    
test = test.replace(/'[(.+?)']/, '$1');
alert(test);

更新
test = "FIFA publishes its results according to IFRS. The total compensation for the management committee in 2011 was 30 million for 35 persons. Blatter, the only full time, earns approx 2 Mio CHF, 1.2 Mio fix, the rest bonus.[4][5][6]";
test = test.replace(/'[(.+?)']/g, '$1');//for global replace
alert(test);
<标题>更新演示