Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Get First name from full name

A3006May 21 2021

Hi all,
I have a scenario where in I have different forms of data in a column NAME in a table.
Now I need to segregate it into First name and last name.
I have tried regular expression but it is either a pass for one scenario and fail for the other and vice versa.

Suppose I have data like
NAME
MERCEDES BENZ - > FNAME TO BE MERCEDES, LNAME TO BE BENZ

ALISHA CHENOY ALI - > FNAME TO BE ALISHA, LAST NAME AS CHENOY ALI

ALISHA-CHENOY, ALI -> FNAME TILL COMMA, ALI TO BE LNAME

ALISHA CHENOY, ALI - > SAME AS ABOVE

ALI'SHA CHENOY, ALI - > SAME AS ABOVE.

My general approach was to extract till the first comma is encountered or till the first space. But in some cases I have a space followed by comma.

Can anyone please be kind enough to help me with this.

This post has been answered by Jason_(A_Non) on May 21 2021
Jump to Answer
Comments
Post Details
Added on May 21 2021
8 comments
767 views