title: Replace last comma separated value by another using regex
body: <p>I have a string as follows :</p>
  
  <pre><code>var str = "a,b,c,a,e,f"; 
  </code></pre>
  
  <p>What I need is replace the last comma separated element by another.</p>
  
  <pre><code>ie, str = "a,b,c,a,e,anystring"; 
  </code></pre>
  
  <p>I have done it using <code>split</code> method and adding it to make a new string. But it is not working as expected</p>
  
  <p>What I done as follows :</p>
  
  <pre><code>var str = "a,b,c,d,e,f";
  
  var arr = str.split(',');
  
  var res = str.replace(arr[5], "z");
  alert(res);
  </code></pre>
  
  <p>Is there any regex to help?</p>