Skip to Content
0

UDF for remove leading Alphabates from an Input field

Dec 14, 2016 at 06:03 AM

54

avatar image
Former Member

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

10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

4 Answers

Best Answer
Evgeniy Kolmakov Dec 14, 2016 at 06:57 AM
1

Hi Raju!

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

Regards, Evgeniy.

Show 4 Share
10 |10000 characters needed characters left characters exceeded

Eve this will remove all the characters irrespective of postion I guess.

0

Yes, Raghu! I'm just assuming that there shouldn't be any alphabets in the rest parts of the string as Raju said about integer value he needs to get ;-)

Regards, Evgeniy

0

Okies. Eve.if not my code should work.:)

0

Yes, but I guess it needs to be slightly changed by transferring prefix length from constant value to function argument (as prefix might have variable length) :-)

Regards, Evgeniy.

0
Evgeniy Kolmakov Dec 14, 2016 at 06:27 AM
0

Hi Raju!

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

Regards, Evgeniy.

Show 1 Share
10 |10000 characters needed characters left 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

0
Raghuraman S Dec 14, 2016 at 06:43 AM
0

Hello Raju,

Try the below code

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


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