Thread: Parsing names
View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Rick Rothstein Rick Rothstein is offline
external usenet poster
 
Posts: 5,934
Default Parsing names

That's not the case. You just add to the "title" section whatever
titles you wish to handle. For example, if you also want to handle
MD, DDS, and LLD, you would just use:

^(\w+)\s+(?:(Jr|Sr|III|II|IV|MD|DDS|LLD)\s+)?(?:(\ w\w+)\s+)(?:([A-Z])\s+)?

The regex does require that you know what titles you wish to use
ahead of time, but there's no need to modify it each time.


What I meant is that if an **unanticipated** title comes along, your code
would have to be modified to account for it. For example, if out of the blue
a name with an unanticipated title such as Esq. comes along... your code
would not be able to handle it until Esq was added to the RegEx pattern.

This may also be of value if the OP needs to check validity of entries.


Yes, I agree with that, which is why I included this statement in my
posting...

"...as long as you know the entries will always be names
and not just gobbledygook, everything should work fine"

Rick Rothstein (MVP - Excel)