jquery - Split input name attribute in nested rails form with javascript -


first off, having trouble describing issue. apologize in advanced if not seeing existing answer online. how can split string array each entry text within each set of square brackets. here string:

plan_year[benefit_groups_attributes][0][relationship_benefits_attributes][1][premium_pct] 

what need store value in second set of square brackets. in example [0]. .split hasn't given me result wanted, , think because doing

.split(/[[]]/); 

should expect work?

var s = 'plan_year[benefit_groups_attributes][0][relationship_benefits_attributes][1][premium_pct]'; s.match(/\[.*?\]/g)[1]; # "[0]" 

Comments

Popular posts from this blog

python - Alternative to referencing variable before assignment -

vb.net - How to ignore if a cell is empty nothing -

Sort a complex associative array in PHP -