var quote = 'some text here [[quote=bob]This is some text bob wrote[/quote]] other text here';
我正在尝试获取[[quote=bob]这是鲍勃写的一些文字[/quote]]
。
我正在使用:
match(/[[quote=(.*?)](.*?)[/quote]]/)[1]
但它给了我这里一些文字[[quote=bob]这是鲍勃写的一些文字[/quot
最佳答案
试试这个:
var quote = 'some text here [[quote=bob]This is some text bob wrote[/quote]] other text here';
console.log( quote.match(/(\[\[quote=(.*?)\](.*?)\[\/quote\]\])/) );
// [1] => "[[quote=bob]This is some text bob wrote[/quote]]"
// [2] => "bob"
// [3] => "This is some text bob wrote"
关于JavaScript 正则表达式匹配 [[quote][/quote]],我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26807458/