JSFiddle - React, Tailwind, and code Playground
HTML
<input class="form-control required_specify name_specify replace_k" type="text" name="processDefs[2][name]" value="" data-name="name">
<input class="form-control required_specify name_specify replace_k" type="text" name="processDefs[2][status]" value="" data-name="status">
<button>Replace!</button>
CSS
textarea{
height:250px;
width:500px;
}
JavaScript
$('button').click(function () {
$('.replace_k').each(function(){
var name = $(this).data('name');
var obj = $(this);
$(this).attr('name').replace(/\d+(?=\]\[)/g, function (match) {
match = Number(match) + 1;
return obj.attr('name','processDefs['+match+']['+name+']');
});
});
});