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

Removing specified caracters from string

Former Member
0 Likes
924

Hi all,

i have the following variable string :

DATA: ld_str type char100 value 'un TRES UN Dos Un Tres uN'.

Well, i need to remove all 'un' whatever the case sensitive. At the end i need to have the following string value : 'TRES Dos Tres'.

I supppose i need to use regular expression but i don't know to work with them.

Thanks for your help

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
842

Hi Eric,

Use the following code for removing the specified characters from the given string.

REPLACE ALL OCCURRENCES OF REGEX <your_pattern> IN <your_string> WITH space IGNORING CASE.

EX:

REPLACE ALL OCCURRENCES OF REGEX 'un' IN 'un TRES UN Dos Un Tres uN'

                       WITH space IGNORING CASE.

Output :

TRES Dos Tres

6 REPLIES 6
Read only

Former Member
0 Likes
843

Hi Eric,

Use the following code for removing the specified characters from the given string.

REPLACE ALL OCCURRENCES OF REGEX <your_pattern> IN <your_string> WITH space IGNORING CASE.

EX:

REPLACE ALL OCCURRENCES OF REGEX 'un' IN 'un TRES UN Dos Un Tres uN'

                       WITH space IGNORING CASE.

Output :

TRES Dos Tres

Read only

0 Likes
842

I forgot option 'IGNORING CASE', it's work fine, thanks a lot

Read only

Former Member
0 Likes
842

Hi,

try this code

DATA: ld_str TYPE char100 VALUE 'un TRES UN Dos Un Tres uN'.

REPLACE ALL OCCURRENCES OF REGEX 'un' IN ld_str WITH space.

condense:ld_str.

WRITE:ld_str.

Read only

Former Member
0 Likes
842

Hi Eric,

   REPLACE ALL OCCURRENCES OF 'UN' in ld_str WITH ' ' IGNORING CASE.
   CONDENSE ld_str.

Regards,

Azhar

Read only

Former Member
0 Likes
842

hi ,

Try this code

data: ld_str type char100 value 'un TRES UN Dos Un Tres uN'.
   replace all occurrences of 'un' in ld_str with space IGNORING CASE.
   write:ld_str.

Regards

Kannan

Read only

Former Member
0 Likes
842

can you try this?

DATA: ld_str type char100 value 'un TRES UN Dos Un Tres uN'.


REPLACE ALL OCCURRENCES OF 'un' in ld_str WITH space

IGNORING CASE .