Reputation: 17
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
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