(→Searching and Search Options) |
|||
| Line 46: | Line 46: | ||
;Search("|D|D") | ;Search("|D|D") | ||
:Search for two consecutive digits using pattern matching. | :Search for two consecutive digits using pattern matching. | ||
| + | |||
| + | ===Regular Expressions=== | ||
Regular expressions can also be used when the "REGEXP" option is specified. | Regular expressions can also be used when the "REGEXP" option is specified. | ||
| Line 54: | Line 56: | ||
<div class="callout note">The configuration parameters '''{CONFIG, Search, Default case sensitive option}''' and '''{CONFIG, Search, Default search mode}''' have no effect on the '''Search( )''' and '''Replace( )''' commands.</div> | <div class="callout note">The configuration parameters '''{CONFIG, Search, Default case sensitive option}''' and '''{CONFIG, Search, Default search mode}''' have no effect on the '''Search( )''' and '''Replace( )''' commands.</div> | ||
| − | The '''[SEARCH]''' function saves the current search string so that it can be reused | + | ===[SEARCH] and [SEARCH AGAIN]=== |
| − | by '''[SEARCH AGAIN]'''. You can do the same thing in Command Mode by | + | |
| − | using the command option "SET": | + | The '''[SEARCH]''' function saves the current search string so that it can be reused by '''[SEARCH AGAIN]'''. You can do the same thing in Command Mode by using the command option "SET": |
;Search("house",SET) | ;Search("house",SET) | ||
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.
The text to search for is specified with a "search string". Usually the search string consists of the exact characters you want to locate.
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.
You can directly search for the 'n'th occurrence with the command form Search("string", COUNT, n). For example:
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".
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.
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.
The search string can include any desired pattern matching codes, just like [SEARCH]. For example: (The "|" is the keyboard character above "\".)
Regular expressions can also be used when the "REGEXP" option is specified.
The [SEARCH] function saves the current search string so that it can be reused by [SEARCH AGAIN]. You can do the same thing in Command Mode by using the command option "SET":
Following the example above, [SEARCH AGAIN] would search for the string "house". There is an equivalent to [Search AGAIN] in command mode:
One difference between a "search" and a "search again" is that the "search" begins at the current edit position, while the "search again" begins with the character following the current edit position. Otherwise, a "search again" would tend to match the same text over and over again.