trim @domain.xxx from email leaving just username
To find:
int index = string.indexOf('@');
To replace:
email = email.substring(0, index);
To summarize:
email = "[email protected]";
int index = email.indexOf('@');
email = email.substring(0,index);
Another approach is to split an email on a nickname and on a domain. Look at javadoc
There is a code example:
String email = "[email protected]";
String[] parts = email.split('@');
// now parts[0] contains "example"
// and parts[1] contains "domain.com"