0

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
1
  • He might have suggested this (MD|DDS|DMD|DO|etc.)$ . Try it and let me know. Commented May 4, 2017 at 19:01

1 Answer 1

1

Here's one way to get the license (less any trailing whitespace):

select regexp_matches(last_name, '(MD|DDS|DMD|DO|etc)\s*$') AS license from table;
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.