cancel
Showing results for 
Search instead for 
Did you mean: 

how to split the field value in several segment

Former Member
0 Kudos

hi experts,

my input field value length is 2000 characters.

but my question is how to split the 2000 characters in to several segment example in 70 characters in one segment like that

Accepted Solutions (0)

Answers (3)

Answers (3)

Former Member
0 Kudos

Hi Pratima.

You can use this UDF code



public static void  splitBySize(String inputList[], String sizeSplit[],

 int targetLen = 0;
        int sourceLen = 0;
        int count = 0;
        int pos = 0;
        for(int i = 0; i < inputList.length; i++)
        {
            if(i < sizeSplitList.length)
                targetLen = Integer.parseInt(sizeSplit<i>);
            sourceLen = inputList<i>.length();
            count = sourceLen / targetLen;
            for(pos = 0; pos < count * targetLen; pos += targetLen)
                result.addValue(inputList<i>.substring(pos, pos + targetLen));

            if(pos < sourceLen)
                result.addValue(inputList<i>.substring(pos));

Where inputList...-- The values of Segment

sizeSplit...-- The value of Split.(in your case 70)

baskar_gopalakrishnan2
Active Contributor
0 Kudos

Use substring java string method using UDF to achieve this

Example:

String str ="123434";
String str2 = str.substring(2,str.length());

Shabarish_Nair
Active Contributor
0 Kudos

you will have to code a UDF with a subString to get this done.

A pointer is as in this thread -