Reputation: 551
I'm a beginner with pentaho data integration and I want to split a string with the following form : FIRSTNAME LASTNAME CODE I want to isolate the firstname and lastname from the code noting that the lastname can contain more than a word. I thought about spliting all the string based on space separator but the problem is that the name can sometimes be composed of more than two words. Can you show me please the steps to follow to acheive that?
Upvotes: 2
Views: 10715
Reputation: 153
Split the rows with Step "Split Fields". Then concatenate the fields for lastname1 or lastname2OrCode if person has 2 last names, otherwise set the code field.
And this simple Javascript (Do not forget to click at Get variables)
var lastname;
var code;
if(codeTmp==null){
code = lastname2OrCode;
lastname= lastname1;
}else {
lastname = lastname1+ " "+ lastname2OrCode;
code = codeTmp;
}
Upvotes: 2