I Have a form with multiple input text like:
<div class="width-height">
<input value="" name="items[1][width]" type="text">
<br>
<input value="" name="items[1][height]" type="text">
</div>
<div class="width-height">
<input value="" name="items[2][width]" type="text">
<br>
<input value="" name="items[2][height]" type="text">
</div>
I try to get with a JS foreach "number" and "width" or "height" in an array
the best result possibility should be an array with 2 value in console.log:
1,width
1,height
2,width
2,height
I try 2 regex :
// first: /\d\]\[[a-z]+/i
// second: /\d\]\[\w+/g
$('.width-height > input').each(function () {
console.log("1 : " + $(this).attr('name').match(/\d\]\[[a-z]+/i));
console.log("2 : " + $(this).attr('name').match(/\d\]\[\w+/g));
});
but the result is only:
1 : 1][width
2 : 1][width
I have tried to use uncapture setting for excluding part that I don't need :
console.log("3 : " + $(this).attr('name').match(/(?:\w+\[)\d(?:\]\[)\w+/g));
but it return only 1 string
3 : items[1][width
I guess I don't understand something in regex.. with non-capture and "g" flag i think it should return all possibility without capture and build an array with retrieving value but .. not.. :-/
Tranks for your help!