What I would like to achieve is to create a script that would move the last word in a string to the beginning of it. Additionally, a comma and a space should be added to the last word. Here is an example of this:
Code: Select all
John Smith
John Anderson Smith
John A. Smith
J.A. Smith
Code: Select all
Smith, John
Smith, John Anderson
Smith, John A.
Smith, J.A.
Code: Select all
RegExReplace(string, "^(.+?)\s+(\S+)$", "$2, $1")
But how about names starting with with e.g. 'van' etc? They should be changed as follows:
Code: Select all
John van Smith -> van Smith, John
participle := "della,von dem,van der,Van der,van de,de,De,der,van,Van,’t"
And last thing: some people have after their surname strings like: Jr, Sr, II, III, IV.
Code: Select all
Jim E. Deer, Jr.
Joe L. Smith Sr
Bob van der Sloot IV
Code: Select all
Deer, Jim E., Jr.
Smith, Joe L., Sr
van der Sloot, Bob, IV