Search code examples
integrationtalend

how to replace special characters in talend integration



i want to replace special charecters in talend integration.
Example Records are:

id                  mrp
013SB X121MULTI     7633
013SB/X121MULTI     46696
013SBX121MULTI      8531
013SBX121MU*LTI     4939
013SBX121MULTI      1347
013SBX121MULTI      5388
013SBX121MULTI      53592
013SBX_121MULTI     449

Expected Results are

    id                  mrp
    013SBX121MULTI      7633
    013SBX121MULTI      46696
    013SBX121MULTI      8531
    013SBX121MULTI      4939
    013SBX121MULTI      1347
    013SBX121MULTI      5388
    013SBX121MULTI      53592
    013SBX121MULTI      449


special charecters contained in 1,2,4 and last record.i want to replace special charecters like (space,_,-,*,etc..,)
can anyone suggest for this problem


Solution

  • You can easily use tJavaRow to clear id field. In tJavaRow you can do everything what Java allows you to do with these data. Firstly we need to find way to remove special chars from String. According to these solution we can add in tJavaRow component something like this:

    output_row.id = input_row.id.replaceAll("[^\\w]","").replaceAll("_", "");;
    output_row.mrp = input_row.mrp;