title: replace() regex multiple line break string not working javascript
body: <p>I have the next string bbcode type <code>[MSG]abc[/MSG]</code> which I want to replace by a friendly string....using a regex</p>
  
  <p>My code works when the bbcode is in the first line only, but when I put some more text within the <code>[MSG]</code> tag with line breaks....it doesnt work....</p>
  
  <p>What am doing wrong?</p>
  
  <p><strong>CODED TRIED</strong></p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>$("button").on("click", function(){
  var textarea = $("#textarea").val();
   var regex = /\[MSG\](.*)\[\/MSG]/ig;
  
     
     textarea = textarea.replace(regex,"converted: $1 --");
     
  
  $("div").text(textarea)
  
  })</code></pre>
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/1.8.0/jquery.min.js"&gt;&lt;/script&gt;
  
  hello [MSG]abc[/MSG]
  &lt;HR&gt;
  hello [MSG]a &lt;BR&gt;
  
  bc[/MSG]
  &lt;HR&gt;
  &lt;textarea id='textarea' rows=3&gt;
  hello [MSG]abc[/MSG]
  /
  hello [MSG]a 
  
  bc[/MSG]
  
  &lt;/textarea&gt;
  
  &lt;button&gt;convert&lt;/button&gt;
  &lt;div&gt;&lt;/div&gt;</code></pre>
  </div>
  </div>
  </p>