[resolved] Removing everything after a specified character

One Star

[resolved] Removing everything after a specified character

I am new to Talend and fairly new to anything JAVA/scripting related so would really appreciate your help.
I have a range of telephone numbers which I would like to clean up using the tMap component.
I have successfully managed to remove spaces etc, however in this field, my company has stored a lot of telephone extensions so typically the number would look like this: 
092081146x713
I would like to remove everything after the 'x' and then store the value after the 'x' in a variable and then populate the another column with the data after the 'x' so that the telephone extension is not lost when we migrate our systems next year.
Please help Smiley Happy
Caz


Accepted Solutions
Six Stars

Re: [resolved] Removing everything after a specified character

Hi Caz,

You could try this,It works

For the phone number-row1.phone.split("x") [0] 
For the phone extension-row1.phone.split("x") [1] 




Thanks,
Regards,
Avinash

View solution in original post


All Replies
One Star

Re: [resolved] Removing everything after a specified character

use tMap and str.substring(str.lastIndexOf("x") + 1) ?
Six Stars

Re: [resolved] Removing everything after a specified character

Hi Caz,

You could try this,It works

For the phone number-row1.phone.split("x") [0] 
For the phone extension-row1.phone.split("x") [1] 




Thanks,
Regards,
Avinash

View solution in original post

One Star

Re: [resolved] Removing everything after a specified character

Thanks guys...will test this in about an hour Smiley Happy
will let you know how it goes...
Highlighted
One Star

Re: [resolved] Removing everything after a specified character

Thanks j1122, this worked like a charm Smiley Happy

2019 GARTNER 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

Best Practices for Using Context Variables with Talend – Part 2

Part 2 of a series on Context Variables

Blog

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