Search Strings
The commands DE (Delete), L (Locate), R (Replace), SP (SPlit) and TR (Truncate) allow you to specify search text. The operation is only performed on those lines that contain matching text.
String delimiters
When using these commands, a string delimiter is used to separate the different syntax elements. It can be any nonnumeric character, except a space or minus sign, that does not appear in the search or replacement text. The slash (/) character is the most commonly used character for a string delimiter; it is used in most examples in this section.
Note that, when used as a delimiter, the colon (:) anchors the search to the starting column (see Column Dependent Matching).
In the DE (Delete) and L (Locate) commands, using the hash (#) as a delimiter negates the search; only lines that do not contain the search text are deleted or listed.
Wildcard character
The caret character (^) can be used within the search string to match any single character; for example, /s^t/ matches "sat", "set" and "sit" (and, of course, "s^t").
The caret (^) command can be used to toggle wildcard mode on and off. With wildcard mode off, the caret character matches only a literal caret character; /s^t/, for example, matches only "s^t".
Note
Attribute marks, value marks and subvalue marks are displayed as carets (^), right-hand brackets (]) and backslashes (\) respectively. When searching for these, or for literal carets, right-hand brackets or backslashes, ensure that you have entered the correct characters. Attribute marks, value marks and subvalue marks can be entered with ctrl+^, ctrl+] and ctrl+\ respectively.
Case sensitivity
You can choose whether your search strings match in a case-sensitive or -insensitive way. For example, if you search for "FRED", this will match "Fred", "FRED" and "fred" if the search is case-insensitive but only "FRED" if it is case-sensitive. Whether searches are case-sensitive or -insensitive can be selected as follows:
-
You can select the required mode when you start the editor with the U (sensitive) or Y (insensitive) option. If you use neither of these options, the current data case setting is used (set with the DATA.CC environment option or the CASE TCL command).
-
You can change the case setting with the CI, CS and = editor commands.
Note that, if you are editing multiple items, the current setting is retained when you open a new item.
Column-dependent matching
The commands that use search text also allow you to specify a range of columns; they will then only match lines where the position of the search string is within the specified range. For example, the command
L/John/5-99
finds the next line containing the text "John" anywhere in columns 5 to 99. It therefore displays the line
My name is John. ("John" is in columns 12 to 15)
but not the line
John is my name. ("John" is in columns 1 to 4)
Note
The end column defaults to the same value as the starting column. Because of this, if you omit the end column, your search text must be a single character; it will match only if found in the specified location.
The colon (:) is a reserved delimiter that "anchors" the match to the first column specified; this means that to match, the search text must start that column. For example, the command
L:John:12-99
Would find the line
My name is John. ("John" starts in column 12)
but not the line
I am called John. ("John" starts in column 13)
If you do not specify a starting column, the colon delimiter anchors the match to column 1; to match, a line must start with the search string.