Skip to main content
Announcements
SYSTEM MAINTENANCE: Thurs., Sept. 19, 1 AM ET, Platform will be unavailable for approx. 60 minutes.
cancel
Showing results for 
Search instead for 
Did you mean: 
NNYEZEL
Contributor
Contributor

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

1 Solution

Accepted Solutions
ThWabi
Creator II
Creator II

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

 

View solution in original post

3 Replies
ThWabi
Creator II
Creator II

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

 

NNYEZEL
Contributor
Contributor
Author

Hi,

The solution almost work 0683p000009MPcz.png

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 0683p000009MPcz.png

Thanks for all your help

NNYEZEL
Contributor
Contributor
Author

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]