var a = 'testAbc123def'; 
b = a.replace(/[^0-9]+/ig,"");
alert(b);
b = a.replace(/[^a-z]+/ig,"");
alert(b);