title: Replace double quotes with brackets in nested HTML elements
body: <p>I am trying to create a script to replace all my double quote texts to be insert inside brackets.</p>
  <blockquote>
  <p>Eg:
  Input : This &quot;is&quot; a &quot;text&quot;.
  Output : This [is] a [text].</p>
  </blockquote>
  <p>I have tried to fetch all the text elements and using regex replace and print the bracekts.</p>
  <p><strong>But it is not working as expected for nested elements.</strong></p>
  <p>This is my code sample</p>
  <p><strong>HTML</strong></p>
  <pre><code> &lt;p&gt;this &quot;is&quot; a &quot;text&quot; 
     &lt;small&gt;this is &quot;small&quot; text&lt;/small&gt;
   &lt;/p&gt;
   &lt;h1&gt;&quot;this&quot; is &quot;another&quot;&lt;/h1&gt;
  </code></pre>
  <p><strong>Javascript</strong></p>
  <pre><code>$(document).ready(function(){
          $('p, h1, h2, h3, h4, h5, div, span, small, b, strong, li').each(function(){
  
                  var re = /([^&quot;]*&quot;[^&quot;]*)&quot;/gm; 
                  var str = $(this).text();
                  var subst = '$1»'; 
                  var result = str.replace(re, subst);
                  var resultOdd = result.replace(/&quot;/g, '«');
                  $(this).text(resultOdd);
              
          });
  
  
          
  
      })
  </code></pre>
  <p><a href="https://jsfiddle.net/hakkim/387sxnce/" rel="nofollow noreferrer">This is the fiddle for the same.</a></p>
  <p>Can anyone please help me?</p>