I want to extract the server name from a string using Substring. I am not sure if I should iterate a loop or with StringTokenizer, indexof, lastindex or what ever.
Basic requirement is, I should use substring()
For example:
id@yahoo.com , my@gmail.com etc
This goes in paragraph and should print server names like this:
Server names: yahoo, gmail ...
Sample Runs (for single inputs):
Input: mario@google.com Output: google
Input: alvaro.arbeloa@realmadrid.com Output: realmadrid
Input: luigi@forest.yahoo.com Output: forest
EDIT: If your emails are not separated with commas or any other delimiters, then you can extract individual e-mail addresses with this code:
Denote that I’m not using
trim()this time. After this splitting, you can again use the same for-loop above.