Probably the best answer here is not to try. Names are individual and idiosyncratic, and even limiting the Western tradition, you can never be sure that you will think about all cases. One of my friends legally changed his name by one word, and he had time dealing with various institutions whose procedures could not cope with this. You have a unique position that you create software that implements the procedure, and therefore you have the opportunity to develop something that will not annoy the crap of people with non-traditional names. Think about why you need to sort out your last name first and see if there is anything else you could do.
This, as they say, is a purely technical issue, the best way would probably be, in particular, to cut the strings "junior", "junior", "junior", "III", ", III", etc. from the end of the line containing the name, and then get everything from the last space in the line (new, after removing Jr, etc.). It wouldn’t get, say, “Del La Hoya” from your example, but you can’t even count on the person to get it - I accept the reasonable assumption that the name of John Mark Del La Hoya is “Del La Hoya” and not “ Mark Del La Hoya "because I am a" native English speaker "and I have some kind of intuition about what Spanish surnames look like - if it were a name, say" Gauthip Yeidze Ka Illunyepsi ", I would absolutely not I knew to consider that Ka as part of a surname or not, because I have no idea what language it is.
source share