ProgramEdit

Search Help

PgmEdit - Search Dialog Fields

PgmEdit home

The Search functions can be used to Highlight, Find, or Replace text in the current file, or File Find or File Replace text in multiple files.

Tip - The Highlight, Find, and Replace functions report the number of "Text to finds" that are highlighted, found or replaced.  This information is shown in the Status bar (bottom of PgmEdit window).

Sections 1-5 below describe the possible fields and check-boxes in the Search dialog window while Section 6 provides a number of Regular Expression Examples.

1.  Text to find - Literal, All Words, or Regular Expression

Tip - If the Up Arrow is pressed when the Search Dialog window is first opened, the word at the Caret or the selected word(s) in the editor will be loaded into the "Text to find" box.

The "Text to find" field can be a Literal (an exact match of the text including leading and trailing spaces), or a space-separated list of all the "Words" required in a line (if the "All Words" box is checked), or a Regular Expression (if the "Regular Expression" box is checked).

For example, if Text to find is "cat" (do not enter the quotes), the software will search for the word cat - it will not matter in this case if All Words or Regular Expression are checked or not, since there is only one word and there are no Regular Expression Special characters.

However, if Text to find is "cat mouse" and All Words is checked, the software will search for lines that have both the word cat and the word mouse (in any order).

However, if Text to find is "cat|mouse" and Regular Expression is checked, the software will search for lines that have either the word cat or the word mouse (or both).  If this a Highlight operation, both "cat" and "mouse" will be highlighted.  Note that the "|" is a Regular Expression Special character that acts as an "Or" operator.

A detailed reference for Microsoft Regular Expressions is at Regular Expression Language - Quick Reference

Text to find - Literal

If All Words and Regular Expression are not checked, the text is treated as a Literal.

Text to find - All Words (Find or File Find dialog)

If All Words is checked, the text is treated as an All Words expression.  Refer to section 5. CheckBox Options/All Words for a detailed description and examples of the All Words option.

Text to find - Regular Expression

If Regular Expression is checked, the text is treated as a Regular Expression.

There are twelve Regular Expression special characters:   . $ ^ { [ ( | ) * + ? \

These characters are used to provide logic or wildcards for a Regular-Expression Text to find.

To Find an RE Special character literally, the Special character must be "escaped" by preceding the character with a "\" character.  For example, to find "$" when the Regular Expression box is checked, enter Text to find as "\$"

Highlight Text to find - Regular expression "\n" not colored

If "\n" (NewLine) is used in "Text to find" of a HighLight Regular Expression, NewLine characters (LF) will NOT be highlighted (NewLines are not visible).

This only applies to Highlight.  Find and Replace work properly for a Regular Expression with "\n".

Find All

For Find and File Find, the Find All button opens a Search_Results child window which lists all file lines that contain the specified "Text to find".  Clicking the View menu or double-clicking on a listed line will go to that file line and select the "Text to find".

Note - Clicking on the Search_Results Export menu will copy the Search Results to a "New?" window.

2.  Replace with - Literal or Regular Expression

The "Replace with" field defines the Replacement text.  It can be either a Literal or a Regular Expression (if the Regular Expression box is checked).

Note that for a Replace, the Regular Expression syntax is completely different than the syntax for a Find.  For example, the Special characters and Character Escapes do not apply to the "Replace with" text.  One exception, as implemented in PgmEdit, is "\n" which will replace the Find text with a NewLine.

For a Regular Expression Replace, "$" indicates the beginning of a substitution.  Refer to the Substitutions section of the Regular Expression Language - Quick Reference: Substitutions

3.  File filter - File spec/Wildcards * ?

The "File filter" field is used to limit which files are searched.   Wildcard characters "?" and "*" can be used: "?" matches exactly one character, while "*" matches 0 or more characters.
For example * or *.* will search all files in the Folder specified, while *.cpp will only search C++ files.

Multiple File filters - *.cpp | *.h

Two or more File filters can be specified by separating each filter with character number 124 "|".  For example *.cpp|*.h (or *.cpp | *.h) will search all files having the extension .cpp or .h .

File filter including Folder - C:\Espresso SOURCE\*.cpp

The File filter can include the directory of the file.  For example C:\Espresso SOURCE\*.cpp will search *.cpp files in the C:\Espresso SOURCE folder.
For this Filter, the Folder field is not used, although the Folder field must contain a valid path such as "." (current/working directory) or the path used for any other Filters that do not include a directory.

File filter - Exclude files - *.cpp : exclude-text

The File filter can be used to "thin out" the files to be scanned by specifying part of the full file path-name(s) to be excluded.  Each exclude-text item must be preceded by a space-colon-space (" : ").

Example 1 - A File filter of " *.cpp : Copy " will scan all .cpp files except those with "Copy" in their full file path-name.

Example 2 - A File filter of " *.cpp | *.h : debug : designer " will scan all .cpp and .h files except those with "debug" or "designer" in their full file path-name.

Note 1 - The " : exclude-text" items are case-insensitive

Note 2 - The " : exclude-text" items must be at the end of the "File filter" field

4.  Folder - Directory path & name

The Folder field specifies which directory will be searched.
If "Search sub-directories" is checked, Folder sub-directories will also be searched.

5.  CheckBox Options

Selected Text only - If text is selected and "Selected text only" is checked then Highlight, Find, Find All, Replace, and Replace All are restricted to the selected text.

Match Case - If "Match case" is checked then Highlight, Find or Replace are case-sensitive.

All Words - Highlight, Find, File Find

Highlight - If "All words" is checked in the Highlight dialog, all of the space-separated "words" in "Text to Find" will be highlighted.  The "words" can be any mix of characters (letters, numbers, symbols) except for the Space character (the word separator).

Find/File Find - If "All words" is checked in the Find or File Find dialog, clicking Find or Find All will search for lines that contain all of the space-separated "words" in "Text to Find".  The "words" can be any mix of characters (letters, numbers, symbols) except for the Space character (the word separator).

Tip - Find/File Find "All Words" will find lines with all of the specified "words" (in ANY ORDER).  For example, a "Text to find" of "File Load" will find lines with FileLoad, File_Reload, File is Loaded, Load an HTML File, LoadFile.

When a line is found, the first longest-word in "Text to Find" is selected.  For the above example, "File" will be selected.

Any Word - Not a CheckBox

Tip - A logical "Or" search of a group of words (find lines that have at least one of the words) can be done by checking the "Regular Expression" box and separating the words with a vertical bar character ("|").

Regular Expression - If "Regular expression" is checked, the "Text to find" and "Replace with" fields are Regular Expressions.

Search Sub-directories - If "Search sub-directories" is checked, Folder sub-directories will also be searched.

List Lines - If "List lines" is checked, all lines that contain the "Text to find" are listed;   otherwise only the file names are listed.

6.  Regular Expression Examples

The below table lists a few Regular Expression examples and the corresponding result:

Tip - do not enter the quotes ("...") and check the "Regular Expression" box


Text to Find Find or HighLight Result
1.
"\t" Find or HighLight Tab characters (Hex 09)
2.
"cat|dog|mouse" Find all occurrences of the words "cat", "dog", or "mouse"
3.
"file.*char|char.*file" Find all lines that have the words "file" and "char" in either order
4.
"[1-9]?[0-9]\." Find numbers "1." to "99."
5.
"[^ \t\n]" Find all non-whitespace characters (Not space/Tab/NewLine)

Text to Find Replace with Find-Replace Result
1.
"^ *\n"   "" (blank) Find & Delete line if it contains only 0 or more spaces
2.
"[ \t]+$" "" (blank) Find & remove Trailing Whitespace of a line
3.
"(d)(o)(g)" "$3$2$1" Reverse the order of the three letters in the word "dog"
4.
"(\n)" "$1$1" ("\n\n") Double-space single-spaced lines
5.
"," "\n" Replace "," with NewLine.   Items in a comma-separated list, eg "a,b,c", will placed on separate lines
NOTE: "\n" is a PgmEdit-only Regular Expression substitution