var id = '#id_name_01'
var pattern = /\d+/
var id_only_digits = id.match(pattern);
--
>>> id_only_digits
<<< ["01"]
$('#id_name_01').click(function(){
var id_digits = $(this).attr('id').match(pattern)[0];
$('#other_id_' + id_digits).somefunction();
});