'getting the "title" between the names

The name I'm working on is formatted like this:

King, Mr. Jay Thomas
Smith, Miss. Jane

How do I get the middle title part only using Postgres?

I'm a noob so this is definitely wrong:

SELECT position('%#,"  #"%#' for '#') AS TITLE
FROM  titanic;`


Solution 1:[1]

You could use SUBSTRING with the regex pattern \w+\.:

SELECT SUBSTRING(title from '\w+\.')
FROM titanic;

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Tim Biegeleisen