var str = "例如匹配到[url = baidu.com]百度[/url]";var reg = /\[url[\s\=]+([^\[\]]+)\]([^\[\]]+)\[\/url\]/g;str = str.replace(reg, "$2");console.log(str);