cancel
Showing results for 
Search instead for 
Did you mean: 

substring

Former Member
0 Kudos

hi all,

i have a dilemma regarding substring. i need to cut a value based on the first character. foe example, file-123888. I need to get the characters after the - symbol. Result should be 123888. I know I have to use a UDF but I'm not that good in JAVA. Please help

Thanks!

IX

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

I'd go for an even more "flexible" way :

String substr = str.substring(str.indexOf("-")+1,str.length());

so you do not need to declare static position and length and if the begin pattern changes, it will deal with it

Chris

Answers (2)

Answers (2)

Former Member
0 Kudos

Hi,

I need to get the characters after the - symbol.

Means u want all the things after "-".

and the length may vary also after "-".

So please use the

String k = "abc-addd";

System.out.println(k.substring(k.indexOf("-")+1));

Thanks & Regards

Babu

rajasekhar_reddy14
Active Contributor
0 Kudos

Hi,

Search in sdn,you wil find the code for the same,

it is very easy pass input to the udf and use substig function

str is here your input

String str = string.substring(6,11);

retunr str;

Regards,

Raj