var str = "user=true;auth=openid;location.href='https://vk.com/auth/jDHSHjk=089&jhGAJ99aU-_83jhASIhdisajoidsa'"; var res = str.substring(str.indexOf("href='")+6, str.length-1); alert(res);