title: How to replace one punctuation with and or & randomly using javascript
body: <p>am trying to remove the punctuations which are followed by punctuations and I have done it but I need to replace the last but second punctuation mark in sentence with and or &amp; randomly.</p>
  
  <p>Here is the code</p>
  
  <pre><code> &lt;html&gt;
     &lt;head&gt;
        &lt;script&gt;
             $( document ).ready(function() {
                  for(var i=0;i&lt;2;i++)
              {
                  var remove_dot=document.getElementsByTagName("p")[i];
                  var remove=remove_dot.innerHTML;
                  remove_dot.innerHTML = remove.replace(/[,|.-]+[\s]*([,|.-])/g, "$1");
                 }
                });
         &lt;/script&gt;
       &lt;body&gt;
           &lt;p&gt;hello , . are you | . why , its ok , .&lt;/p&gt;
           &lt;p&gt;hey , . are you | . why | its ok , .&lt;/p&gt;
       &lt;/body&gt;
  </code></pre>
  
  <p>With the help of above script am able to remove the punctuations followed by punctuation mark
  Here is my output</p>
  
  <pre><code> hello . are you . why , its ok .  
   hey . are you . why | its ok .
  </code></pre>
  
  <p>But as I need to replace the second last punctuation randomly with and,&amp; how can I modify the regexp
  Here is my expected output.</p>
  
  <pre><code>      hello . are you . why and its ok .  
        hey . are you . why &amp; its ok .
  </code></pre>