Skip to Content
avatar image
Former Member

UDF for remove leading Alphabates from an Input field

Hi Experts,

Can You help me out in UDF for removing leading characters.

My Input =ORPO000000001,ORPC0000000002,ORPR00036548

Expected output is(000000001,0000000002,00036548) remove leading alphabates

transform the integer value only .

Please help me on this with UDF

Thanks,

Raju

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

4 Answers

  • Best Answer
    Dec 14, 2016 at 06:57 AM

    Hi Raju!

    public String removeCharacters(String var1, Container container) throws StreamTransformationException{
    return var1.replaceAll("[a-zA-Z]", "");
    }

    Regards, Evgeniy.

    Add comment
    10|10000 characters needed characters exceeded

  • Dec 14, 2016 at 06:27 AM

    Hi Raju!

    Why just not to use standard function "substring" for that?

    Regards, Evgeniy.
    Add comment
    10|10000 characters needed characters exceeded

    • Former Member

      Hi Kolmakov,

      But in feature input value may be change (ORPR00036548 to ORPRW000365489)

      That's why we are unable to use "substring"

      Thanks,

      raju

  • Dec 14, 2016 at 06:43 AM

    Hello Raju,

    Try the below code

    input=input.substring(4,input.length()-4);
    return input;


    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Dec 14, 2016 at 08:00 AM
    public String remLeadChars(String var1, Container container) throws StreamTransformationException{
    return var1.replaceFirst("[a-zA-Z]+(?!$)", "");
    }
    
    Add comment
    10|10000 characters needed characters exceeded