I have a list of last names that can have variations like this-->DOE, JR., DO. What I need is a Postgres pattern matching or substring function that will split the DO from the last name and put that a separate column. However, if the pattern is like this DOE, JR. I don't want those split off names suffixes, only professional titles which I need to list like MD, DDS, DMD, or DO. Someone I work with suggested I use something like this -->Substring(last_name, ‘[MD, DDS, DMD, DO,etc.]$’) but that is not working.
select substring('.do' FROM last_name) AS license from table
(MD|DDS|DMD|DO|etc.)$. Try it and let me know.