cancel
Showing results for 
Search instead for 
Did you mean: 

Logic of UDF Code

Former Member
0 Kudos

Hi PI experts,

I'm not familiar with Java code but I should work on an existing UDF in a mapping. I would like to ask what does the code below do, as I can't understand this section:

String b= (a.substring(11,a.indexOf('.'))).replaceFirst("_", "");

where "a" is the file name and retrieved using the code for DynamicConfiguration

I tried to find some answers in the forum but didn't found the details I am looking for, specially this one used three functions/methods in a single line (substring + indexOf + replaceFirst).

Thanks!

Accepted Solutions (1)

Accepted Solutions (1)

udo_martens
Active Contributor
0 Kudos

Hi,

that means:

Take from the filename character number 11 up to first dot found. And replace from the result the first found underline with nothing.

abcdefghijklm_nop.qrm -> klmnop.

(very risky operation, if the file name is to short or does not contain a dot, you get stringIndexOutOfBoundException)

Regards,

Udo

Former Member
0 Kudos

Hi Udo,

Now I understand. Thanks a lot! (points given)

Answers (0)