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 Manipulation using Syntax Rule

Former Member
0 Likes
688

Hello all,

I would like to modify a sting in that way that the characters, defined by a specific syntax, should be cleared. E.g., the following syntax: <[C|CC]>, all elements which begin with the '<' character and ends with '>' character. The characters '<' and '>' enclose one or two characters.

E.g. I have the following string: 'Hermann Hesse was born <b><B></b>125<b></></b> years ago'.

After conversion the Syntax should contain: 'Hermann Hesse was born 125 years ago'.

I tried the classical way using <b>REPLACE ALL OCCURENCES</b>, but it didn’t work.

Thank you for your hints.

Regards,

Kurt.

Message was edited by: Kurt Weiskopf

Message was edited by: Kurt Weiskopf

1 ACCEPTED SOLUTION
Read only

RichHeilman
Developer Advocate
Developer Advocate
0 Likes
647

Hi Kurt. Please check the following sample program.



report zrich_0001.


data: string(100) type c.
data: start type i.
data: end type i.
data: len type i.

string = '<b>This</> is really <b>fun</>'.

do.

  search string for '<'.
  if sy-subrc <> 0.
    exit.
  endif.

  start = sy-fdpos.

  search string for '>'.
  end = sy-fdpos.

  len = ( end - start ) + 1.

  string+start(len) = space.

  condense string.
enddo.

write:/ string.

check sy-subrc = 0.

Regards,

RIch Heilman

5 REPLIES 5
Read only

RichHeilman
Developer Advocate
Developer Advocate
0 Likes
648

Hi Kurt. Please check the following sample program.



report zrich_0001.


data: string(100) type c.
data: start type i.
data: end type i.
data: len type i.

string = '<b>This</> is really <b>fun</>'.

do.

  search string for '<'.
  if sy-subrc <> 0.
    exit.
  endif.

  start = sy-fdpos.

  search string for '>'.
  end = sy-fdpos.

  len = ( end - start ) + 1.

  string+start(len) = space.

  condense string.
enddo.

write:/ string.

check sy-subrc = 0.

Regards,

RIch Heilman

Read only

RichHeilman
Developer Advocate
Developer Advocate
0 Likes
647

Hi Kurt. If this worked for you, please remember to award points for helpful answers and mark as solved when solved completely. Thanks.

Regards,

Rich Heilman

Read only

Former Member
0 Likes
647

You can also use FM SOTR_TAGS_REMOVE_FROM_STRING. It seems to work for simple cases.

Rob

Read only

0 Likes
647

thanks to Rob.. I stumbled upon SOTR_STRING_PARSER which seems to be quite useful too..

~Suresh

Read only

0 Likes
647

Hello all,

thanks for your helpfull hints. The programm is now working properly.

Regards,

Kurt.