Question ID : 276
Created on 2016-06-29 at 8:23 AM
Author : Veryant Support [email@example.com]
Online URL : http://support.veryant.com/support/phpkb/question.php?ID=276
Usually to replace a text into a string you can use the "inspect replacing" statement. But, with this kind of approach, the original text and the new text must have the same length.
To avoid this problem you can use the "C$REPLACE_ALL" routine.
This routine uses the "regular expression" syntax in the search string and in the replace string
call "C$REPLACE_ALL" using wrk-str search-string replace-string crep-right-trimmed w-error giving wstatus
"wrk-str" is the variable that contains the string to manage, and before the execution of the routine it contains the original text, while after the execution it contains the new text.
"search-string" is a variable that contains the "regular expression" used to find the text to be replaced.
"replace-string" is a variable that contains the "regular expression" for the new text.
"crep-right-trimmed" is a constant used to change the behavior of the routine. The possible value can be "CREP_CASE_INSENSITIVE", "CREP_LEFT_TRIMMED" and "CREP_RIGHT_TRIMMED"
"w-error" is a variable that contains the error description if there is one.
"wstatus" is a variable that contains the status of the execution.
For example, to change the string "Today is a rainy day" to "Today is a very sunny day"
move "Today is a rainy day" to wrk-str call "C$REPLACE-ALL" using wrk-str "rainy" "very sunny" crep-right-trimmed w-error giving wstatus
Back to Original Question