Arbortext Command Language > Commands > substitute
  
substitute
 
substitute [ -b | -f] [ -c | -noc] [ -a] [ -e | -noe] [ -wrapscan | -nowrapscan] [ -q | -noq] [ -markup] /oldtext/newtext/
This command searches for oldtext and replaces it with newtext.
* 
If you have applied an alias map to the document, the oldtext string can include aliases and real names. However, the newtext string cannot contain aliases.
-a replaces all occurrences of the string oldtext with the string newtext. If -wrapscan is specified, the command replaces all occurrences in the document. If -nowrapscan is specified, the command replaces all occurrences from the current cursor position to the end of the document.
-b searches backward.
-f (the default) searches forward
-c performs a case-sensitive search.
-noc (the default) finds a string regardless of how it is capitalized. The set case command sets this parameter for all subsequent searches.
-e specifies that the search string is a regular expression. In regular expressions, some punctuation characters (such as *, +, ?, \, and .) perform special actions. For example, find -e /p..t/ (where the . is a placeholder representing any character) would match “pret”, “port”, and “part”, as well as the string “p..t”.
-noe (the default) specifies the search string is not a regular expression. The set expressions command sets this parameter for all subsequent searches.
-wrapscan (-ws) (the default) causes the search to wrap to the beginning of the file when the end is reached.
-nowrapscan (-nows) prevents the search from wrapping. The set wrapscan command sets this parameter for all subsequent searches.
-q (for “quiet”) suppresses the “string not found” message generated when a search fails. This is useful when putting the find command in command files or aliases.
-noq (the default) displays a message when Arbortext Editor cannot find a string that matches the search string.
-markup (-m) indicates that the oldtext and newtext strings contain one or more tags or entities. Tags are indicated by surrounding angle brackets; an end tag contains a slash. Entities start with an ampersand (&) and end in a semicolon (;).
* 
Substituting tag names requires a balanced tag specification. That means if you specify a newtext entry of <para>Beginning of a paragraph, it's not valid because it's not balanced by a </para> end tag. You would need to specify <para>paragraph text</para> to be valid.
When performing a case-insensitive substitution (sub -noc /Never/rarely/, for example), the replacement is capitalized according to how it was specified, not according to what it replaces (in this example, Never and never would both be replaced with rarely).
You must supply either a matching close delimiter or place the string at the end of a line. For instance, sub -c /therefore/Therefore if it's the end of a line and sub -c /therefore/Therefore/ are both valid.
Examples
substitute /the/THE
substitute -b /here/there
s -f /here/there
s -c /here/there/
s -a /and/AND/
s -a -m /<_newline>//
s -e /Eg...t Wil..n/Myrna Jones/
s '(John)(Smith)'\2,\1' -e
Related Topics
Using regular expressions
find command