Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

string entries deletion

Former Member
0 Likes
540


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.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
503

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

3 REPLIES 3
Read only

Former Member
0 Likes
503

use SPLIT into table command. It will split your string into table lines, you can specify the splitter - which is in your case "/".

Read only

Former Member
0 Likes
504

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

Read only

ThangaPrakash
Active Contributor
0 Likes
503

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