As a learning exercise, I created a person-type attribute and wrote a stamp with action code that breaks the FullName attribute into first name, middle name, last name, and suffix attributes. Had to figure a way to account for punctuation and Roman Numerals. The result is a bit prolix but it gets the job done.
Really nice and thoughtful Paul! Thank you for sharing.
A great example beause Full Name is common and complicated because of its variety⊠esp with prefix and suffixâs. What if we compared vName.at(0) with known_prefiix and the the (-1) with the known_suffix.
Then grow the list as needed.
Question (with respect and probably further behind in regards to programming experience): Why would you not use the list syntax
vName[0] âŠetc instead of the current vName.at(0)?
Interesting. This might also be of passing interest: Myths Hackers Believe About Names. Some are purely programming concerns but some of the early ones are pertinent.
In truth the internet age and the digital primacy of (American) English conventions in software code and design mean many of the above are falling away as software canât cope with ânormalâ names from other locales. So much for the global village.
I donât think the above invalidates your approach but it does mean you do need to review the output for mis-parsing. Recently completing a 2.9k database of international names gave me pause for thought about my starting assumptions as mis-naming, even innocently done, can cause upset.
This RegEx matches the words without spaces. Tinderbox is saving the $1.
([^\s]+)$
This RegEx matches the Last Word.
(?<=\s).*(?=\s)
This RegEx captures everything in the middle.
I realize that this DOES not address issues like people with two last names or two first names, nor does it capture the prenominal or postnomials. However, in my use case, I have some control over if they are in the name or not. It might be fun to build some of the conditions to capture those.
Donât forget the lastWord( ) and firstWord( ) operators.
split( ) is useful, too.
Doing this with the streaming operators makes an interesting exercise. Though I was skeptical at first, I do believe it can be done without undue contortions.
How do you handle these two variable situations that occur in some names and not others:
1. Names +/- prefix: âMr., Mr, Mrs., Mrs, Ms, Dr.â
2. Names +/- a suffix: âJr, II, MD, PhDâŠâ
Iâve not played with it. If/when Iâd do Iâd put in some if conditions, e.g., first work has â.â then X, and/or less the x characters, if name has more than y words, etc.