Link to home
Start Free TrialLog in
Avatar of Michael Franz
Michael Franz

asked on

Spliting Domain out from email address.

Hello,

I have the following email addresses:

michael.help@imlost.com
sahar.cool@insurance.com


I need to get the domain (ie. insurance.com) split off the right side because I need to write an if statement after this looking something like the following.

For example....

if(domain == null) ||(domain == "insurance.com")
{
"Employee"
}
else
{
"Other"
}
Avatar of Radek Baranowski
Radek Baranowski
Flag of Poland image

String s="some.email@somedomain.com";
int indexOfAt= s.indexOf('@');
String domain= s.substring(indexOfAt+1);
if(domain == null) ||(domain == "somedomain.com")
{
"Employee"
}
else
{
"Other"
}

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of Rainer Jeschor
Rainer Jeschor
Flag of Germany image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Michael Franz
Michael Franz

ASKER

I'm getting an error....I cut the IF off for the time being...


String s="some.email@somedomain.com";
int indexOfAt= s.indexOf('@');
String domain= s.substring(indexOfAt+1);

missing; before statement, line 28: String s=
AWESOME!!!! Yea thank you. Easy and it works!