-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.

Ja͢ck
  • 170,779
  • 38
  • 263
  • 309
XTRUST.ORG
  • 3,280
  • 4
  • 34
  • 60

1 Answers1

0

Try

'[quote="username"]This is a comment string[/quote]'.replace(/\[quote="(.*?)"\](.*?)\[\/quote\]/, function(text, g1, g2, pos, content){console.log('a', g1, g2); return 'd'})
Arun P Johny
  • 384,651
  • 66
  • 527
  • 531