GREP to change firstname lastname to lastname, firstname with exceptions
- August 25, 2023
- 5 replies
- 1602 views
Hi everyone,
I've reviewed a number of posts about this but haven't found a script that works for my situation.
I have an index of about 1600 authors for a book catalogue. The index generated as [firstname lastname pagenumber/s] but I need it to be [lastname, firstname pagenumber/s]. However, I have a lot of out of the ordinary names - initials, hyphenated, multiple authors for one book, three names, European glyphs, nicknames and aliases - and the page numbers add another level of complexity. Some examples are:
A. M. Homes 49
Andrew O’Connor 9
Andrew X. Pham 45
Anja Reich-Osang 62
Anne Tyler 20, 37, 38, 40, 41
Behrouz Boochani & Omid Tofighian 55
Catherine de Saint Phalle 24
Charlotte Brontë 12
Chimamanda Ngozi Adichie 8, 53
Claire Bidwell Smith 55
Colm Tóibín 45
D.B.C. Pierre 63
F. Scott Fitzgerald 33
Irène Némirovsky 56
Isabel ‘Spark’ Gill 29
Kenneth Cain, Heidi Postlewait & Andrew Thomson 59
Robert Galbraith (J.K. Rowling) 59
ZZ Packer
Ursula K. Le Guin 34, 35, 36
I've tried a some of the GREP scripts I've found here in the discussions with little success.
Find ^(.+)(, ?)(.+)
replace $3$2$1
Find ^(\w+)(\s)(\w+)$
replace $3$2$1
Any assitance would be appreciated. The full index is attached
Cheers,
Di
