cancel
Showing results for 
Search instead for 
Did you mean: 

UDF for each input character separated with semicolon

Former Member
0 Kudos

Can any one tell me how can i get an output with each character from input string separated with semicolon

e.g

Input : ABCD

Output : A;B;C;D (Semicolon separated)

Accepted Solutions (1)

Accepted Solutions (1)

former_member204873
Contributor
0 Kudos

Create an UDF having one input value:

and use:

String x = "ABCD"; -- input

String out = "";

int y = x.length();

for(int p = 0;p<y; p++){

if(p != y-1){

out = out + x.charAt(p) +";";

}

else{

out = out + x.charAt(p);

}

}

return out;

Answers (3)

Answers (3)

Former Member
0 Kudos

Thanks to all

Former Member
0 Kudos

Hi, just check this

char[] inp_str;

String out = "";

inp_str = input.toCharArray();

for(int i=0; i<inp_str.length; i++)

{

out = out + inp_str<i>+";";

}

return out;

This is working, just add square brackets of i after inp_str.

Edited by: Ravi on Apr 1, 2010 10:39 AM

Former Member
0 Kudos

Hi Use this code

Here var1 is the input parameter of array time, means it is queue type UDF

char[] stringArray;

stringArray = var1[0].toCharArray();

for(int i=0; i < stringArray.length; i++)

result.addValue(stringArray<i> + ";") ;

Note: result.addValue(stringArray [ i ] + ";") ; in this statement after stringArray and before and after i open_square_bracket and end_square_bracket are not visible here so make sure you use this braces in your code

Regards

Ramesh