This topic describes the search and replace commands Search( ) and Replace( ) which correspond to the functions as clicking Search then Search or clicking Search then Replace.

Searching and Search Options

The text to search for is specified with a "search string". Usually the search string consists of the exact characters you want to locate.

Search("today")
Search for the next occurrence of "today".

Like any string argument, the search string must be enclosed in delimiters that are not part of the search string. If the search is successful, the "edit position" is placed at the first character of the matched text, e.g. at the "t" of "today". If not, the command gives the error message "CANNOT FIND "string" - search errors can also be suppressed.

Sometimes it is preferable to have the edit position placed past the matched text, e.g. immediately after the "y" of "today". For example, this is convenient when a following block operation needs to include the matched text. This is easily done with the "ADVANCE" option.

Search("today",ADVANCE)
Search for the next occurrence of "today"; if found, place the edit position past the matched text.

You can directly search for the 'n'th occurrence with the command form Search("string", COUNT, n). For example:

Search("today",COUNT,7)
Search for the 7th occurrence of "today".

All searches are normally forwards, toward the end of the file. However, you can also search backwards toward the beginning of the file by using the command option "REVERSE".

Search("house",REVERSE)
Search backward for the nearest occurrence of "house".

When searching, vEdit normally equates upper and lower case letters. However, when needed, the command option "CASE" can be used to distinguish between upper and lower case letters.

Search("house",CASE)
Make a distinction between upper and lower case letters. This search with not match "House".

Sometimes you want to search for a distinct "word" that is separated from other characters with spaces or other separators. For example, you might want to search for the word "and", but not match "sand", "Anderson" or other words that contain "and". For this use the "WORD" option.

Search("and",WORD)
Restrict the search to distinct words. This search will not match "band".

The search string can include any desired pattern matching codes, just like [SEARCH]. For example: (The "|" is the keyboard character above "\".)

Search("|D|D")
Search for two consecutive digits using pattern matching.

Regular expressions can also be used when the "REGEXP" option is specified.

Search("[A-Z][a-z]*",REGEXP)
Search for a capitalized word using Regular expressions.
The configuration parameters {CONFIG, Search, Default case sensitive option} and {CONFIG, Search, Default search mode} have no effect on the Search( ) and Replace( ) commands.