我有这样的字符串:Stackoverflow is a useful Forum for [all][people][over the world] and I like this rum
我想从上面的字符串中获取文本以获得结果:
text1 = "all";
text2 = "people";
text3 = "over the world";
我有这样的字符串:Stackoverflow is a useful Forum for [all][people][over the world] and I like this rum
我想从上面的字符串中获取文本以获得结果:
text1 = "all";
text2 = "people";
text3 = "over the world";
干得好:
var str = 'Stackoverflow is a useful Forum for [all][people][over the world] and I like this rum';
var matches = str.match(/\[.*?]/g);
console.log(String(matches[0]).replace( /(^.*\[|\].*$)/g, '' ));
console.log(String(matches[1]).replace( /(^.*\[|\].*$)/g, '' ));
console.log(String(matches[2]).replace( /(^.*\[|\].*$)/g, '' ));