var str =' getDevice22 ( a , b, asd , j,i) '; str = str.replace(/\s+/g,''); var arg = str.replace(/.*?\((.+)\).*/,'$1'.split(',')); if(arg!=str) alert(arg); else alert('Не найдено!')