cancel
Showing results for 
Search instead for 
Did you mean: 

please hepl, mapping string using "endWith".

Former Member
0 Kudos

Hi experts,

I am trying to map a string field to another using following mapping logic:

if source field ends with "_" and any substring, just pass the substring.

for example: if source field is "Custumer_name", pass "name" to the destination field

if source field is "Java_class", pass "class" to the destination field

any idea how to do this with XI built in functions or java mapping?

thanks

Accepted Solutions (0)

Answers (5)

Answers (5)

ravi_raman2
Active Contributor
0 Kudos

Why do we complicate code....when its so easy..indexOf is not even needed here......

String function, Substring function, use a string.split("_"), that will split the string at the _ character and give you the result.............

Like i said imam....if you need simple code, just lemme know

Regards

Ravi Raman

justin_santhanam
Active Contributor
0 Kudos

use this

int index = a.indexOf('_');

int len =a.length();

if( index == -1)

{

return ""a"";

}

else

{

String ret = a.substring(index+1,len);

return ""ret"";

}

Best regards,

raj.

Former Member
0 Kudos

Imam,

You need to write a user defined funciton for this. Create a <b>Value</b> user defined function and name it as <b>GetValue</b>. Take one parameter 'a'.

Add this code:

int k = a.length();

int i = a.indexOf(".");

i = i +1;

a = a.substring(i,k);

return(a);

So it returns the value after -.

---Satish

ravi_raman2
Active Contributor
0 Kudos

Imam,

This is pretty easy to do with java mapping....

try splitting the string with a delimiter...and if this is not clear with java,

let me know and i can write the code you need..

Regards

Ravi

Former Member
0 Kudos

Hi,

Write a user defined function. We cannot achive this by using builtin function.

Juct check the string in user defind function and when encounters _ pass the value.

regards

Hemant