f-angi
12/23/2015 - 2:39 PM

Extracts a part of a string using a RE

Extracts a part of a string using a RE

var x = $('input[name=tipoSceltaLegale]:checked').attr('id').match(/radio-legale-(.+)/)[1];
// x === 'arag'
<input id="radio-legale-network" type="radio" checked="checked" value="network" name="tipoSceltaLegale">
<input id="radio-legale-arag" type="radio" value="arag" name="tipoSceltaLegale" checked>