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

resizing Telegram inline keyboard -

command line - How can a Python program background itself? -

php - "cURL error 28: Resolving timed out" on Wordpress on Azure App Service on Linux -