-3

I have a string like below:

[quote="username"]This is a comment string[/quote]

Pattern 1: username Pattern 2: This is a comment string

Is it possible to replace this to get:

<div class="myclass">
   <b>username</b>
   <i>This is a comment string</i>
</div>

Thanks.

4

1 回答 1

0

尝试

'[quote="username"]This is a comment string[/quote]'.replace(/\[quote="(.*?)"\](.*?)\[\/quote\]/, function(text, g1, g2, pos, content){console.log('a', g1, g2); return 'd'})
于 2013-06-17T06:15:25.947 回答