Skip to Content
avatar image
Former Member

Replace dots with space using Replace

Hi,

I have a field which has 008.2009.

I need to extract the contents before DOT character or just ignore the contents after DOT character.

Used replace string function but just replaces the DOT character with space.

Without UDF, let me know whether it is possible using std functions.

Regards

Krish

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

6 Answers

  • Best Answer
    avatar image
    Former Member
    Sep 23, 2009 at 11:29 AM

    Is your requirement just to get 008 in the target field?

    If yes then this can be achieved using the IndexOf function and then based on the value returned by the IndeOf function do a substring and have only the part before dot.

    If above is the requirement then it can be easily achieved using a UDF....a very simple UDF.

    Update:

    I dont think standard functions will help.....the substring function will need the ending location of the string (in your case 8)....this is actually passed as length....hence UDF is required....any specific for avoiding UDF?

    Regards,

    Abhishek.

    Edited by: abhishek salvi on Sep 23, 2009 5:00 PM

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Sep 23, 2009 at 11:31 AM

    Hi Krish,

    If the dot always appears after three digits (numbers) then you can use the substring function.

    Using substring you can get numbers before dot (008).

    UDF is not required to achieve this if the DOT always appears after three digits.

    Let me know what output string do you exactly need?

    Regards,

    Gautam Purohit

    Edited by: Gautam Purohit on Sep 23, 2009 1:32 PM

    Add comment
    10|10000 characters needed characters exceeded

  • Sep 23, 2009 at 11:35 AM

    Hi,

    Map Like this..

    input---->UDF---->Output

    UDF Code is

    return a.substring(0,a.indexOf('.'));

    Only one line code...

    Thanks.

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Sep 23, 2009 at 11:36 AM

    create a UDF with one argument a

    return a.substring(0, a.indexOf("."));
    

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Sep 23, 2009 at 12:33 PM

    Hi,

    This is not possible without UDF, you need to use simple udf code for this.

    Parameter = String.

    char[] temp1 = new char[inputfield.length+1];
    char[] temp = new char[inputfield.length+1];
    
    temp = inputfield.toCharArray();
    
    for(int i=0; temp.length()>i;i++)
    {
      temp1<i> = temp<i>;
       if(temp<i>.equals('.'))
               break;
    
       result.addValue(String.valueof(tem1p<i>));
    }
    
    

    Thanks

    Swarup

    Thanks

    swarup

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Sep 23, 2009 at 11:33 AM

    it is not possible with the standard function you have to use UDF

    Add comment
    10|10000 characters needed characters exceeded