Uday's website
Published on Uday's website (https://uday.net)

Home > SAP Technical > How-To > Replace HTML tags in a string

Replace HTML tags in a string

Suppose you want to change "<HTML><B>Sample Text</B></HTML>" to "Sample Text".

Use following function modules.

SOTR_TAGS_REMOVE_FROM_STRING

HRDSYS_CONVERT_FROM_HTML

SWA_STRING_REMOVE_SUBSTRING

 

Other option is to use Regular Expressions.

DATA: message TYPE string.
message = '<p style="something">Hello <strong>World</strong>!</p>'.
REPLACE ALL OCCURRENCES OF REGEX '<[a-zA-Z\/][^>]*>' IN message with space.
WRITE:/ message.

 

 

 

  • Log in [1] to post comments

 Valid XHTML 1.0 StrictCreative Commons LicenseVerbatim copying and redistribution of this entire page are permitted provided this notice is preserved. All content on this website including archives (including text, photographs, audio files and any other original work), unless otherwise noted, is licensed under a Creative Commons License or later.


Source URL:https://uday.net/replace-HTML-tags-in-a-string

Links
[1] https://uday.net/user/login?destination=node/536%23comment-form