cancel
Showing results for 
Search instead for 
Did you mean: 

UDF Required to get string before Pipe

Former Member
0 Kudos

Hello All,

   Could anyone help me with UDF to get the string before pipe.

   I have a requirement where data will populate as below

       Source data:    Human Resource | Administration ---> Output i need to get is Human Resource

                             

                             Finance Accounting | Finance   --->  Output i need to get is Finance Accounting

                             Sales | Representatives    --->  Output i need to get is Sales

                             Communications | Community Relations   ---> Output i need to get is Communications

                             If there is no Pipe then i need to pass data as it is which is coming from source field.

                             For Ex: Manufaturing ---> output is Manufacturing.

                                         Production    ---> Output is Production.

    Can anyone help me with UDF or if it is achievable with graphical function kindly let me know how to do.

Thanks,

Bhaskar

Accepted Solutions (1)

Accepted Solutions (1)

markangelo_dihiansan
Active Contributor
0 Kudos

Hi Bhaskar,

Just use a single values udf.

Argument is inp type String

Here is the code:


if(inp.indexOf("|")>-1){

     String tmp[] = inp.split("\\|");

     return tmp[0].trim();

}

else{

     return inp;

}

Regards,

Mark

Former Member
0 Kudos

Hi Mark,

  Perfect. Its working fine.

Thank you.

Bhaskar

Answers (0)