jQuery simple clone plugin - change input name format
<p>I'm using simple clone plugin. This is the <a href="https://github.com/pake007/simple-clone" rel="nofollow">github page</a> of that plugin.</p>

<p>As of now it generates input name like </p>

<pre><code>user[projects][0][name]
user[projects][1][name]
user[projects][2][name]
</code></pre>

<p>Can anyone tell me how to generate name like</p>

<pre><code>user[projects_name][0][1]
user[projects_name][1][1]
user[projects_name][2][1]
</code></pre>

<p>I have created a <code>jsfiddle</code> to show you demo.</p>

<p><a href="http://jsfiddle.net/Viruthagiri/YLSdQ/1/" rel="nofollow">http://jsfiddle.net/Viruthagiri/YLSdQ/1/</a></p>

<p>I think this is the function that generates the id.</p>

<pre><code>// append a initial number to elements id, if options[:nested] true, also assign a initial number to the element name
  e.find("input, select").each(function(){
    var old_id = $(this).attr("id");
    $(this).attr("id", old_id+'_0');
    if(option.nested == true) {
      var old_name = $(this).attr("name");
      var reg = /\[\w*\]$/;
      var match = reg.exec(old_name);
      var new_name = old_name.substr(0, match.index) + "[0]" + match[0];
      $(this).attr("name", new_name);
    }
  })
$.fn.regenerate_names = function(number){
    $(this).find("input, select").each(function(){
      var old_name = $(this).attr("name");
      var old_number = old_name.match(/.*\[(\d+)\]/)[1];  // find the last match
      var old_number_index = old_name.lastIndexOf(old_number);
      var new_name = old_name.substring(0,old_number_index) + number + old_name.substring(old_number_index+1);
      $(this).attr("name", new_name);
    });
  };
</code></pre>

<p>Here is the <a href="https://github.com/pake007/simple-clone/blob/master/simpleclone.js#L47" rel="nofollow">full source code</a></p>
