Getting values after symbol

Hi Expert,

I have requirement like below example.

source data is coming like
A/B/C/XYZ

I want to load into target table after last black slash values only like XYZ I need to load into target.
Could you please help me on this requirement.

Thanks,
Madhav


madhavbods (BOB member since 2012-01-06)

Use word_ext() or substr() with -1


Arun.K :us: (BOB member since 2011-10-18)

First find the length of the data you have, and repace the “/” with “##” and find the length. The difference will let you know how may “/” there in the string.

Once you know that you can use word_ext(string, ‘/’, difference) wich will give the last part of the string


amuh10 :uk: (BOB member since 2012-04-11)

Hi Experts,

Thanks for your reply,

But I’m unable to get results with above functions because of my source data is not in one format is like below.
A/B/C/XYZ
A/B/XY
A/B/C/D/XX

I need to load last slash values only like below
XYZ
XY
XX

Thanks,
Madhav


madhavbods (BOB member since 2012-01-06)

Hi,

Try create custom function to find last ‘/’. Like (input $TEXT, local $POSITION and $POSITION_NEXT):

$POSITION = 0;
$POSITION_NEXT = 0;
$POSITION = index( $TEXT, ‘/’, $POSITION);
$POSITION_NEXT = $POSITION;
WHILE ( $POSITION_NEXT > 0 )
begin
$POSITION_NEXT = index($TEXT, ‘/’, $POSITION + 1);
$POSITION = ifthenelse( $POSITION_NEXT > 0 , $POSITION_NEXT, $POSITION);
end
Return $POSITION;

Your string is now:
substr( $TEXT , $POSITION + 1 , length( $TEXT ) - $POSITION )
(change $POSITION with your function)


MSL (BOB member since 2015-04-27)

Hi ,
Try using below ;

word_ext(VAL, -1, ‘/’)
It will give only value after last ‘/’


BOBJFan (BOB member since 2011-09-24)