0


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

RealHowTo
  • 34,977
  • 11
  • 70
  • 85
Suresh Alathur
  • 93
  • 3
  • 12

2 Answers2

1

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;
xto
  • 406
  • 2
  • 8
0

Following code should simply fulfill the requirement. In addition, it will give only an alphanumeric result excluding special characters (NOT only space,_,-,*,etc..,) :

input_row.col1.replaceAll("[^A-Za-z0-9]", "")

This code can be either used in tJavaRow or directly into tMap

Gyan
  • 21
  • 3