gpt4 book ai didi

JavaScript 正则表达式匹配 [[quote][/quote]]

转载 作者:行者123 更新时间:2023-11-28 15:32:24 26 4
gpt4 key购买 nike

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/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com