REX Replacement Strings

NOTE: Any expression may be searched for in conjunction with a replace operation but the replacement string will always be of fixed size.

An expression will be defined one way when given to REX to search for; it will be defined another way when used with the `-r' or `-R' Replace options as the replacement string. The characters "?#{}+" have entirely different meanings when used as part of the syntax of a replacement string, than when used as part of the syntax of expressions or repetition operators.

Replacement syntax is different from expression syntax, and is limited to the following delineated rules.

  • 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 "#" in the replace string will cause the character in that position 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: \Xdd where "dd" is the hexadecimal value.

Copyright © Thunderstone Software     Last updated: Dec 10 2018
Copyright © 2019 Thunderstone Software LLC. All rights reserved.