Re: covert a part of a string into another
Date: 2000/02/11
Message-ID: <87vni6$81h$1_at_nnrp1.deja.com>#1/1
Immo,
I'm assuming you are doing this in an Oracle Form, and that the original string is being stored in an item - I'm also assuming that you are always interested in the last two substrings of the string. If these assumptions are correct, then this code in an appropriate trigger will get you started. You might want to add some more error checking and some error handling to it:
DECLARE
out_string VARCHAR2(100) := ' ';
v_pos NUMBER(3);
v_char CHAR(1);
BEGIN
v_pos := LENGTH(:BLOCK.ITEM);
-- make sure there is something there
IF v_pos > 0 THEN
v_char := SUBSTR(:BLOCK.ITEM,v_pos,1);
-- step thru string backwards, building output string
-- until first backslash found
WHILE v_char != '\'
AND v_pos > 0 LOOP
out_string := v_char || out_string; v_pos := v_pos - 1; v_char := SUBSTR(:BLOCK.ITEM,v_pos,1);END LOOP;
-- add a forward slash
out_string := '/' || RTRIM(out_string);
v_pos := v_pos - 1;
-- if not finished
IF v_pos > 0 THEN
-- repeat process until second backslash found
v_char := SUBSTR(:BLOCK.ITEM,v_pos,1); WHILE v_char != '\' AND v_pos > 0 LOOP out_string := v_char || out_string; v_pos := v_pos - 1; v_char := SUBSTR(:BLOCK.ITEM,v_pos,1); END LOOP; -- replace this backslash too out_string := '/' || out_string;
END IF
END IF;
-- put out_string into whatever you want here... then exit END; Regards,
Paul
In article <38A2D238.51DD3328_at_gmx.de>,
iwetzel_at_gmx.net wrote:
> Hello
>
> I have a simple question
> How can I covert a part of a string into another ?
>
> i would like to change g:\webapp\shop\images\group1 into
> /images/group1
> and g:\webapp\shop\images\group2 into /images/group2
>
> both strings are only know at runtime.
>
> Thanks for any suggestion
>
> Immo
>
> --
> ----------------------------------------------------------------------
>
> Immo Wetzel
> Fachhochschule Stralsund http://www.fh-stralsund.de
> University of applied science
>
>
Sent via Deja.com http://www.deja.com/
Before you buy.
Received on Fri Feb 11 2000 - 00:00:00 CET