A string-replacement item is used to replace one string with another string within the result string. Depending on the command code used, you can replace the left-most, right-most or all occurrences of some string with another one. If the replacement value is omitted or is a null (zero-length) string, the replacement operation acts as a deletion operation.

When a string-replacement item is encountered in the mapping string, it is applied to the result string as it exists at that point in time. Thus, to do string replacement on the ‘final’ result string in a certain way, you would place the string-replacement item last (right-most) in the mapping string.

Because the action of a string-replacement item is applied to the result string and not to the source string, the mapping string can contain additional column-reference operands to the right of a string -replacement item, since the data characters in the source string remain undisturbed in their original locations.

In the following discussion, the command RA will be used for illustrative purposes to generally represent the syntax of all three commands, since their format is identical. When a specific command is intended, the discussion will bring this out.

Syntax of a  string-replacement item:

{  RA  |  RL  |  RR  }   string-replacement-pair  [  column-reference  ]

RA  |  RL  |  RR:

Introduces the string-replacement item.

  • The command RA will Replace All occurrences of first within the result string with second.

  • The command RL Replaces the Leftmost occurrence of first within the result string with second.

  • The command RR Replaces the Rightmost occurrence of first within the result string with second.


Defines a pair of values. The pair is a quoted string set or string-pair, in the format of:

       'first =second'                        -- in string-set notation


       'first'='second'                        -- in string-pair notation

where first and second are text values. The first and second strings need not be of equal length. The first string must not be null. The second string can be null; if so, the replacement operation acts to delete occurrences of the first string.

By default, the casing of the string-replacement-pair uses the current PROFILE CASE setting in effect. This can be overridden by a CC or CT command code, or by using a type code suffix of C, T or X on the string-replacement-pair.

When CASE T mode is in effect, by any means, string comparisons between the first value and the data in the result string is done as case-insensitive; otherwise it is done as case-sensitive.

When you use an explicit type code of T on the string-replacement-pair, the replacement operation is performed as a case-conformant change. If these commands do not have an explicit type code of T but simply ‘inherit’ a PROFILE CASE T or CT setting, comparison of the first value is done as case-insensitive but string replacement copies the second value as-is without attempting to be case-conformant.  String replacement also takes place in  mode if the separator between first and second is a : colon instead of an = equal sign.

Special considerations when using hex strings:  (1) The hex value is always treated as case-sensitive, as if in CASE C mode. (2) The = equal sign that separates the first and second parts in a string set is written as an actual  = equal sign character, the same as in non-hex values. Example: RA'F1F2=F8F9'X. (3) Whether specified as a literal = equal sign or as a hex code, there can be only one equal sign in the hex value if specified as a single string set.  No such restrictions exist if the value is specified as a string pair, like  RA'F1F2'='F8F9'X.

See the Mapping Strings Quick Reference for a concise summary of how case sensitivity and case conformance are handled.


Specifies columns in the result string to be modified. If column reference is omitted, the entire result string can potentially be modified.

If desired, the two values can be specified as a string pair, using the syntax of RA'first'='second'. This form is convenient when your strings contain equal signs as data. When you are not dealing with data having embedded equal signs, the shorter form will be easier to use. When you use the shorter string set form, the string must contain only one = equal sign.

Note. If you use a string pair, the syntax  RA'first'='second' allows for an alternate format, as RC'first':'second' using a : colon instead of an = equal sign. When you do this, the comparison of the first value, and the substitution of the second value, is done in a case-conformant manner, as if a trailing type code of T appeared on both values.

The string-replacement-pair represents potential string replacements that may take place. It is not necessary for the first value to actually exist in the result string. If none are present, it is not an error; no string replacement takes place, and the result string will remain unmodified.

For instance, to replace all occurrences of one with two,  you would use a string-replacement item like


A complete mapping string that used this item would look like:

M"1+ RA'one=two'"


or with the 1+ implied by auto-copy we can shorten this to:


To delete all occurrences of seven,  you would use a string-replacement item like:


Since there is no = equal sign in this string operand, and it is not specified as a string pair, the second value has not been defined, and thus is null. When the commands are using in this way, the R in the command name can be thought of as “Remove” instead of “Replace”. When second is omitted, RA = Remove All, RL = Remove Leftmost, and RR = Remove Rightmost.

In the event the value you wanted to remove has an embedded = equal sign, the full string-pair format is required. For example, if you wanted to remove all instances of  “A=B”  it would require a command like this:


Command-specific details:

    • The RA command will find all occurrences of first and replace them with second, or will delete the value of first wherever it appears, if second is a null string. When RA finds an instance of first and then replaces it with second, as it resumes its scan of the result string, it will not rescan over any of the replacement data. Thus, if you were to specify a command of  RA'Abc=AbcAbc', it would not inspect any of the just-replaced data. The RA logic passes over the second replacement value, continuing on with its scan of the result string at the portion of it that had not yet been examined.

    • The RL command will find the left-most occurrence of first and replace it with second, or will delete the value of first if second is a null string.

    • The RR command will find the right-most occurrence of first and replace it with second, or will delete the value of first if second is a null string.

Created with the Personal Edition of HelpNDoc: Free Kindle producer