|Home » Products » UltraEdit/UEStudio » Menu Commands (UE) » Search|
Article Number: 1327 | Last Updated: Fri, Oct 21, 2011 3:15 PM
This command displays a dialog box for searching the document for the specified text and replacing it with a different text.
The string to search for is specified in the Find What  field and the replace string to be used is defined in the Replace With  field. Single or multi-line strings up to 20,000 bytes may be used in both fields. The search is performed in the direction specified. If the string is not found the search wraps around to the other end of the file and continues the search. If the string is not found a message is displayed.
In addition to searching and replacing printable characters, tab characters and newline (Carriage Return/Line Feed) characters may be searched for or replaced. To specify a Tab character, use "^t" characters in the dialog. To specify the newline characters, use "^p" characters for CR/LF, "^n" for LF only and "^r" for CR only in the dialog. To search for a "^" character, use "^^" in the dialog. To specify a "^" character, use "^^" in the dialog.
Additionally, the characters "^s" will be replaced with any text that is highlighted when a find is executed and the characters "^c" will be replaced with the contents of the clipboard (up to 30,000 characters). This is useful particularly for macros. When recording a macro, the option exists to include a find of a specified character string, or using "^s" the macro records the "^s" and when replayed will determine the text highlighted at the time the macro is playing back, likewise when using "^c", these characters will be replaced with the contents of the clipboard at the time the macro is playing back.
If the button is pressed the Find What / Replace With history is displayed.
If the button is pressed a submenu with the following options is presented:
Special character summary:
Note - ^ refers to the character '^' NOT Control Key + value.
Find next finds the next occurrence of the specified text.
Replace finds the next occurrence of the specified text and replaces it with the new text. The user may also specify Selected Text under the Replace Where  selection and the replace will be limited to the selected area. If the following items are NOT selected in Configuration under the Advanced menu:
Find dialog defaults to word under cursor (Search -> Miscellaneous)
Always set 'Find/Replace Where' to 'Current File' in Find/Replace dialog (Search -> Auto Reset Settings)
the Replace Where option will automatically default to Selected Text when a selection exists.
If All Open Files is selected, pressing Replace will automatically move focus to the first occurrence in the next open file. This functionality replaces the Replace Next through all opened files option from older versions.
Replace all finds every occurrence of the specified text and replaces each occurrence with the new text.
The replace all provides the additional options:
Replace in current file - this replaces all occurrences within the current file only. It determines if the replace should be from the top of the file, or the cursor position based on the setting in this dialog box.
Replace all within the selected text - this replaces only the occurrences of the string that fall within the area of selected text at the time the replace is started.
Replace all in all the open files - this replaces all occurrences of the string in all open files.
The last command performs a single replace and closes the dialog without moving on to the next occurrence of the string.
The following replace options  exist:
Match Whole Word Only
By default, the search will not be restricted to matching whole words only. This option allows the search to be restricted to whole words only. This is useful for searching for 'a', or 'A' without finding all words including 'a'. If a search has already occurred in a document, the default selection will match the previous search.
By default, the search will not be case sensitive. The option to make the search case sensitive is given. If a search has already occurred in the document, the default selection for case sensitivity is that of the previous search. This option also affects regular expressions. If this is not checked, [A-Za-z] and [A-Z] are equal to [a-z].
If this option is selected the search will be executed using the regular expression type selected under the Advanced section.
Advanced Options 
Pressing the Advanced button extends the Find in Files dialog to display additional search options.
Perl Compatible Regular Expressions
If this option is selected the editor will use Perl style regular expressions based on the Boost C++ Libraries.
UltraEdit Style Regular Expressions
If this option is selected the editor will use UltraEdit style regular expressions.
UNIX Style Regular Expressions
If this option is selected the editor will use UNIX style regular expressions.
For information regarding creation of regular expressions see Regular Expressions or Perl Regular Expressions help.
The option to preserve cases causes UltraEdit to match the case of the replace string with the case of the found string. The rules for this are as follows:
1) If the word found is all lowercase the replacement word will be all lower case
2) If the word found is all UPPERCASE the replacement word will be all UPPERCASE
3) If the word found is MixedCase the replacement word will MATCH the casing of the replacement word.
Example: (Find "The", replace with "Then")
"the" will be replaced with "then"
"THE" will be replaced with "THEN"
"The" will be replaced with "Then"
The mixed case example requires the replacement word specified to have the mixed case in the replacement string that is required for the result so that a word that may have multiple mixed case characters may be correctly replaced, not just capitalization as in:
Replace "NextCharacter" with "PreviousCharacter" would replace:
"nextcharacter" with "previouscharacter"
"NEXTCHARACTER" with "PREVIOUSCHARACTER"
"NextCharacter" with "PreviousCharacter"
Replace All is From top of file
If this option is selected the specified search will be executed from the top of the active file rather than the current cursor position.
Close this dialog after replace all
If this option is selected the Replace dialog will automatically be closed after a replace all is executed.
Search In Column
If this option is selected the search will be restricted to the specified start and end columns. The number specified for the end column must be greater than the number specified for the start column (except when searching an entire line). To search an entire line, "0" and "-1" should be used. It is important to note that column numbering begins with "0" so From Col. would have to be set to "0" to search from the beginning of a line.
If the editor active window is in Hex mode, an additional option exists:
By default, in Hex mode, the replace will be for hexadecimal characters. Optionally the replace may be configured to search and replace ASCII characters.
When a find operation is complete the text is highlighted. In Hex mode additional characters may be highlighted if the specified search string crosses a line. In this case, all characters displayed from the first character of the search string on the first line to the last character of the search string on the last line are highlighted. If a replace is requested, only the search string will be replaced.
Undo is supported for Replace All. However if the replace is too large, Undo will not be supported and the Undo buffer will be flushed.
There are no attachments for this article.
Viewed 12264 times since Thu, Oct 13, 2011
Viewed 3578 times since Thu, Oct 13, 2011
Function List command
Viewed 5033 times since Thu, Oct 13, 2011
Find in Files command
Viewed 11228 times since Thu, Oct 13, 2011
Find Next command
Viewed 4251 times since Thu, Oct 13, 2011
Viewed 22645 times since Thu, Oct 20, 2011
Goto Line/Page/Bookmark command
Viewed 7743 times since Thu, Oct 13, 2011
Viewed 5041 times since Thu, Oct 13, 2011
Word Count command
Viewed 11983 times since Thu, Oct 13, 2011
Viewed 5233 times since Thu, Oct 20, 2011