user91599
user91599

Reputation: 17

check character string

hello I would like to test if the string contains the character _ then we do stringHandling.CHANGE(StringHandling.LEFT(row1.B,9),"_","S") nothing else. I do not know how to do it with talend who can help me

 row1.B.contains("_")?StringHandling.CHANGE(StringHandling.LEFT(row1.B,9),"_","S")  

Upvotes: 0

Views: 563

Answers (1)

Yogendra Singh
Yogendra Singh

Reputation: 34367

Don't use ternary operator(? :) in this case as it needs assignment operator in left and tow choices in the right(not suitable).

For single character present check, I prefer indexOf as below:

  if(row1.B != null && row1.B.indexOf('_')>=0){
     StringHandling.CHANGE(StringHandling.LEFT(row1.B,9),"_","S");
 }

Upvotes: 1

Related Questions