Replacement Strings

  • The characters "?#{}+\" are special. To use them literally, precede them with the escapement character "\'.

  • Replacement strings may just be a literal string or they may include the "ditto" character "?'. The ditto character will copy the character in the position specified in the replace-string from the same position in the located expression.

  • A decimal digit placed within curly-braces (e.g. {5}) will place that character of the located expression to the output.

  • A "\" followed by a decimal number will place that subexpression to the output. Subexpressions are numbered starting at 1.

  • The sequence "\&" will place the entire expression match (sans \P and \F portions) to the output. This escape was added in Texis version 7.06.

  • A plus-character "+" will place an incrementing decimal number to the output. One purpose of this operator is to number lines.

  • A "#" followed by a number will cause the numbered subexpression to be printed in hexadecimal form.

  • Any character in the replace-string may be represented by the hexadecimal value of that character using the following syntax: \xhh where hh is the hexadecimal value.


EXAMPLE

<$data = "Roses are red" "Violets are blue">
<$expr = "blue" "red">
<$replace = "you" "dead">
<sandr $expr $replace $data>
<LOOP $ret>
  $ret
</LOOP>

The output would be:

Roses are dead
Violets are you


CAVEATS
The sandr function was added Aug. 23 1996.

The replacements occur in the order of values in $expr, so a later $expr might match a previous $replace value.


SEE ALSO
rex, split


Copyright © Thunderstone Software     Last updated: Sep 25 2019
Copyright © 2019 Thunderstone Software LLC. All rights reserved.