From: Laurenz Albe <>
Date: Fri, 27 Mar 2009 08:43:51 +0100
Message-ID: <>

Dereck L. Dietz wrote:
> I have a query which was designed using a regular expression to get the LAST and FIRST name from a column which had one string in
> the format of LAST, FIRST MI/NAME in one column. It originally worked written as:
> last_name = regexp_replace(name, '(.+), (.+) (.+)','\1')
> first_name =regexp_replace(name, '(.+), (.+) (.+)','\2')
> But now the data we receive has been changed and there are now rows in the data with only a LAST and FIRST names.
> I'm not very familiar with regular expressions so can anybody either show me how or point me to an example of where I could
> possibly handle both possibilities?

I would use regexp_replace(name, ' .*','') for the last name and regexp_replace(name, '[^ ]* *','') for the first name.

Laurenz Albe Received on Fri Mar 27 2009 - 02:43:51 CDT

Original text of this message