Skip to Content
author's profile photo Former Member
Former Member

UDF :Left trim and Right trim

Hey,

I need to do some Left trim and right trim functions. Can anybody share theire experiences with these functions.

If possible provide me the UDF for both.

-S

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

4 Answers

  • Best Answer
    Posted on May 20, 2008 at 06:20 PM

    1) left justify

    function myudf(String a, Container container)

    {

    String r="", s="";

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

    {

    if (a.charAt(i) == ' ' )

    r=s+a.charAt(i);

    }

    return r;

    }

    2) right justify

    function myudf(String a, Container container)

    {

    String r="";

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

    {

    if (a.charAt(i) != ' ')

    r=r+a.charAt(i);

    }

    return r;

    }

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on May 20, 2008 at 04:46 PM

    There is no left trim and right trim function in JAVA

    trim() function will alone trim all left and right whitespaces..

    String str = " dsfdsf ";

    String trimmedStr = str.trim();

    System.out.println(str);

    str=>dsfdsf with no space on left / right.

    Here is your UDF

    a->myudf->targetfield

    function myudf (String a, Container container)

    {

    a=a.trim();

    return a;

    }

    Apart from that in Graphical mapping contains trim() which can be directly used.

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on May 20, 2008 at 04:56 PM

    You can directly use Trim() functions during graphical mapping.

    Its under text functions.

    Gaurav Jain

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on May 20, 2008 at 04:56 PM

    Hi,

    In the standard functions, select TEXT --> trim function, then it will removes white space from the left and right sides.

    If you want to write UDF then.

    Create UDF(select cache type as Value) and give any argument name.(suppose str).

    code

    String trimmedStr = str.trim();

    return trimmedStr;

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.