I am trying to get the First Name and Last Name out of a series of email addresses. There is a pattern for each e-mail address. The pattern is firstname.lastname@example.org but in some cases, it can be something like email@example.com. The main point being that there can be something in between the first and last name in the e-mail but not always.
The main pattern, which is always the same, is that the first string, until the first dot is always the first name, and the last name is always the last character series until the @ char which begins from the previous DOT.
Getting the first name is easy. I have the following variables:
var empmail = 'firstname.lastname@example.org'
var empname = empmail.substring(0, empmail.indexOf("."));
var empmail = 'email@example.com' var fullName = empmail.split('@').split('.'); var firstName = fullName; var lastName = fullName[ fullName.length-1 ]