‎2014 Feb 26 12:33 PM
hi experts
i want to delete the last two value of string....../dirname/filename/1011/abc.txt
i want to replace '1011/abc.txt' with 'Temp'.kindly suggest any way.
last to value in each string lenght before last two strings.
‎2014 Feb 26 1:18 PM
Hi,
you can try using regular expressions:
DATA: filename TYPE string VALUE '/dir1/dir2/dir3/dir4/dir5/file.ccc'.
REPLACE REGEX '(.*)/(.*)/([^/])*$' IN filename WITH '$1/Temp' .
as result filename = '/dir1/dir2/dir3/dir4/Temp'
Marco
‎2014 Feb 26 12:53 PM
use SPLIT into table command. It will split your string into table lines, you can specify the splitter - which is in your case "/".
‎2014 Feb 26 1:18 PM
Hi,
you can try using regular expressions:
DATA: filename TYPE string VALUE '/dir1/dir2/dir3/dir4/dir5/file.ccc'.
REPLACE REGEX '(.*)/(.*)/([^/])*$' IN filename WITH '$1/Temp' .
as result filename = '/dir1/dir2/dir3/dir4/Temp'
Marco
‎2014 Feb 26 1:19 PM
Hello Ankush,
You can even use the offset and delete the entries.
DATA:filepath TYPE CHAR40,
c_lv_filepath TYPE CHAR40,
c_lv_filepath1 TYPE CHAR40.
filepath = '/dirname/filename/1011/abc.txt'.
c_lv_filepath = filepath+0(18).
CONCATENATE c_lv_filepath 'Temp' INTO c_lv_filepath1.
WRITE:/ c_lv_filepath1.
OUTPUT:
/dirname/filename/Temp.
Regards,
TP