Substring First ,Last Name from a FULL Name String in Talend

Highlighted
Five Stars

Substring First ,Last Name from a FULL Name String in Talend

Hi,

I'm new at Talend and I'm trying to do something very simple in  MYSql that I dont know how to do it here

For example:

I have a full neme as : "FName , LName MInitial Title"

I want to subtract just the Name and last name ignoring  the middel initial and the Title.

in sql is replace(SUBSTRING_INDEX (FULL_NAME,' ',2),',','') as NewName

Result : FName  LName

How I can achieve that?

Thanks in Advance


Accepted Solutions
Seven Stars

Re: Substring First ,Last Name from a FULL Name String in Talend

Hello NNYEZEL,

 

assuming that there is a blank before and after the comma, you can split the whole string at the blanks

and use the first and third result of the split. (The second would be the comma.)

 

row1.InputString.split(" ")[0] + " " + row1.InputString.split(" ")[2]

 

Best regards,

 

Thomas

 

Five Stars

Re: Substring First ,Last Name from a FULL Name String in Talend

Hi,

Finally Works.. It take me a minute but is doing what I need...

Thank you for your help

row4.Name.split(",")[0] + " " + row4.Name.split(" ")[+1]


All Replies
Seven Stars

Re: Substring First ,Last Name from a FULL Name String in Talend

Hello NNYEZEL,

 

assuming that there is a blank before and after the comma, you can split the whole string at the blanks

and use the first and third result of the split. (The second would be the comma.)

 

row1.InputString.split(" ")[0] + " " + row1.InputString.split(" ")[2]

 

Best regards,

 

Thomas

 

Five Stars

Re: Substring First ,Last Name from a FULL Name String in Talend

Hi,

The solution almost work Smiley Sad

So the pattern is 'LName' 'space' 'comma' 'space' 'Fname' 'space' 'Mintial' 'Space' 'Title'

FULL NAME STRING =  Test , Name M MD

output is coming as  'Test , M MD'

should be

row1.InputString.split(" ")[0] + " " + row1.InputString.split(",")[1]???

 But is not working Smiley Sad

Thanks for all your help

Five Stars

Re: Substring First ,Last Name from a FULL Name String in Talend

Hi,

Finally Works.. It take me a minute but is doing what I need...

Thank you for your help

row4.Name.split(",")[0] + " " + row4.Name.split(" ")[+1]

2019 GARNER MAGIC QUADRANT FOR DATA INTEGRATION TOOL

Talend named a Leader.

Get your copy

OPEN STUDIO FOR DATA INTEGRATION

Kickstart your first data integration and ETL projects.

Download now

What’s New for Talend Summer ’19

Watch the recorded webinar!

Watch Now

Best Practices for Using Context Variables with Talend – Part 1

Learn how to do cool things with Context Variables

Blog

Migrate Data from one Database to another with one Job using the Dynamic Schema

Find out how to migrate from one database to another using the Dynamic schema

Blog

Best Practices for Using Context Variables with Talend – Part 3

Read about some useful Context Variable ideas

Blog