cancel
Showing results for 
Search instead for 
Did you mean: 

How to find out index of string

former_member350687
Participant
0 Kudos

Hi,

Can you help me to find out index of following strting.

"sss.xxxxx_pain.001.001.02_1002225618.xml"

need to get value "1002225618".

ideally i need to get the value inbetween after second "_"  and value before ".xml".

Thanks

Mahi

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi Mahi,

You can achieve this by UDF. Try with below code

{

int len= var1.length();

int sublen = var1.lastIndexOf("-");

var1=var1.substring(sublen+1, len);

return var1;

}

Regards,

Krupa

allamudi_loordh
Active Participant
0 Kudos

hi krupa,


it should be like this i belive.


var1=var1.substring(sublen+1, len-4);


regards,

Loordh.

Former Member
0 Kudos

Hi Allamudi,

Yes, if he don't want ".xml" in the output text, then len-4 is required.

Regards,

Krupa

former_member350687
Participant
0 Kudos

Hi Krupa,

It is showing some errors

engswee
Active Contributor
0 Kudos

Mahi

The UDF execution type should be simple values, not queue.

Rgds

Eng Swee

Former Member
0 Kudos

Hi Mahi,

UDF should be like this:

If you do not want .xml in the out replace statement

var1=var1.substring(sublen+1, len);

with

var1=var1.substring(sublen+1, len-4);

Regards,

Krupa

Answers (2)

Answers (2)

Former Member
0 Kudos

Hi Mahi,

Please close the thread If your issue resolved.

http://scn.sap.com/community/support/blog/2013/04/03/how-to-close-a-discussion-and-why

Regards,

Krupa

Pranil1
Participant
0 Kudos

Hi Mahi,

Check the below link.

As you have two appearances of  '_', you would require to split whole string at 1st occurence then take the index of remaining string and then proceed according to thread.

Regards,

Pranil.

former_member350687
Participant
0 Kudos

Hi Pranil,

I need to get the value of "1002225618" from "sss.xxxxx_pain.001.001.02_1002225618.xml"

That means i need to get the value after last underscore and value before".xml"

Can you provide me solution