From an email address like something@gmail.com I want to fetch domain name gmail.com.
i want to use that pattern on textbox value in Javascript.
I have just experience a need to implement this and came up with the solution that combines most of already mentioned techniques:
var email = "test@test@gmail.com";
var email_string_array = email.split("@");
var domain_string_location = email_string_array.length -1;
var final_domain = email_string_array[domain_string_location];
So if email has multiple @ characters then you just need to split email string by "@" and calculate how many elements are there in new created array then subtract 1 from it and you can take right element from array with that number.
Here is the jsfiddle: http://jsfiddle.net/47yqn/
It has show 100% success for me!