in reply to Matching Doctors (MD, DR, M.D., DO etc) help

From your descripton and examples, you might be able to simply assume that the last space delimited "word" is the title? In which case something like

my ($lastname, $firstnames, $title) = $name =~ /^\s*([^,]+),\s*(.+)\s+ +(\S+)\s*$/;

might work for you. (That's untested but should give the general idea).

If that fails, post a few examples of those that it fails on and someone will probably be able to improve it for you.

Update: I did a little testing and that regex seems to work provided that the title consists of a single "word" where word is defined as a string on non-space chars, and that is the last non-space string on the line. If you need to seperate out any middle initials, or if there are some without the title present, you'll need to match that word against a list (hash) of possible titles and decide whether it is part of the first names or initial or the title on that basis. If David Robert Smith uses his initials and omits his title, you have a problem:)


Examine what is said, not who speaks.

The 7th Rule of perl club is -- pearl clubs are easily damaged. Use a diamond club instead.

Replies are listed 'Best First'.
Re: Re: Matching Doctors (MD, DR, M.D., DO etc) help
by efreed (Novice) on Jan 16, 2003 at 19:01 UTC
    That was it, when I assume that all titles are at least two characters to avoid middle initials with no title people (Smith, John Q). Many Thanks