I am looking for a Regex to be using in my Java app to split Full Name into First & Last Name parts.
The Full Name will always be separated by " " (Space as Delimiter). some name can consist of Middle Name , But they can be combined with FirstName , i only want to separate Last Name as separate group.
For example :
"This is My Fullname"
LastName = Fullname
FirstName = This is My
So the logic being , anything after Last WhiteSpace is considered as LastName and everything before that as FirstName.
It seemed to me that regular expressions were not really best for this case.
String fullName = "This is My Fullname";
int index = fullName.lastIndexOf(' ');
String lastName = fullName.substring(index+1);
String firstName = fullName.substring(0, index);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With