title: Replace regex with same number of chars
body: <p>I need to replace the content found used a regex with the same number of characters using a character defined by me.</p>
  
  <p>For example:</p>
  
  <pre><code>content: "abcdefghi*!?\"asd";
  </code></pre>
  
  <p>should becomes:</p>
  
  <pre><code>content: "-----------------";
  </code></pre>
  
  <p>This is my regexp:</p>
  
  <pre><code>new RegExp("('|\").*('|\")", "gm")
  </code></pre>
  
  <p>And this is my attempt took from this answer (<a href="https://stackoverflow.com/questions/7456559/javascript-regex-replace-sequence-of-characters-with-same-number-of-another-cha">Javascript Regex- replace sequence of characters with same number of another character</a>):</p>
  
  <pre><code>source_text_safe = source_text.replace(new RegExp("('|\").*('|\")", "gm"), function ($0, $1, $2, $3) {
              return $1 + (new Array($2.length + 1).join("-")) + $3;
          });
  </code></pre>
  
  <p>But it doesn't work.</p>
  
  <p>Using it on this input:</p>
  
  <pre><code>::selected {
      color: purple
  }
  a {
      color: purple
  }
  a:hover {
      color: purple
  }
  a {
      color: purple
  }
  a:not("foobar\";{}omg") {
      content: 'example\';{} text';
      content: "example\";}{ text"
  }
  a {
      color: purple
  }
  </code></pre>
  
  <p>I get this output:</p>
  
  <pre><code>::selected {
      color: purple
  }
  a {
      color: purple
  }
  a:hover {
      color: purple
  }
  a {
      color: purple
  }
  a:not("-117) {
      content: '-150;
      content: "-184
  }
  a {
      color: purple
  } 
  </code></pre>
  
  <p>If I use the regexp replacing the content with <strong><code>null</code></strong> it works fine, so is not a problem of regex.</p>
  
  <p>Any help?</p>