as you can tell from your employee with 3 name indexes
and others with 4 indexes
, “last name” is not a thing you can realistically discern based on its position.
see Falsehoods Programmers Believe About Names | Kalzumeus Software
splitting on something like a space would yield many incorrect results - folks who have (and use/identify with) multiple surnames, as is common in many cultures (spain, for example), or people with a space in their last name.
your current solution would break cases where someone has a legitimate space in their last name, like Van Der Beek
, St. James
, or Lloyd Weber
or Bonham Carter
.
see this previous discussion on this as well.