on-internet
← Community

How to predict whether a name is a surname from an author name string (lexical analysis)

Stack Overflow ·

I'm writing a parser that converts messy author strings into neatly formatted strings in the following format: ^([A-Z]\. )+[[:surname:]]$. Some examples below: Smith JS => J. S. Smith John Smith => J. Smith John S Smith => J. S. Smith J S Smith => J. S. Smith I've managed to get quite far using various regular expressions to cover most of these, but have hit a wall for instances where a full name is provided in an unknown order. For example: Smith John John Smith Smith John Stone Obviously regular expressions won't be able to discern what order the given name, surname and middle name(s) are in

Comments

Sign in or sign up to comment and upvote.

No comments yet.