Let's say I have an email address. Like: kate.daniels@somecompany.com.
And I need to break it apart without using split or loops. And that I need to use IndexOf
in combination with substring and not using a loop (this will come later after I have a strong understanding of this first).
But looking at this email address with the understanding the email addresses are formatted like: (firstName + "." + lastName + "@" + companyName + ".com")
emailAddress = input.nextLine();
// This is where I have issues.
firstName = emailAddress.substring(emailAddress.IndexOf(".") );
// How do I get this to be just the last name and not lastName + "@somecompany.com"
lastName = emailAddress.substring(emailAddress.IndexOf(".") + 1);
// And how do I get the company name without the ".com"
companyName = emailAddress.substring(emailAddress.IndexOf("@") + 1);
Thank you for any help you can provide. I can see how this would be very helpful and would like to learn.
I have looked through and I have not seen a response to my question.