Define Search Pattern [ HP EDIT Reference Manual ] MPE/iX 5.0 Documentation
HP EDIT Reference Manual
Define Search Pattern
Purpose
Enables you to define a search pattern for subsequent search and replace
commands.
Default Syntax
f
Description
This command enables you to define a search pattern so that you can
execute subsequent search commands or search and replace commands. You
can specify a search pattern consisting of a string up to 80 characters
in length. You can also use special pattern-matching characters with the
search pattern to customize subsequent searches.
Command Process
When you execute the command, HP EDIT prompts you for the search pattern.
[REV BEG]Type the desired search pattern and pattern-matching characters,
if any. You can also select a block of text to use for a search
pattern.[REV END] The search pattern remains until you execute the
command again and type another search pattern. After specifying the
search pattern, you can execute one of the available search commands or
search and replace commands.
When you execute the command again, HP EDIT displays the current search
pattern on the message line. If you press the Return key without
specifying another search pattern, HP EDIT retains the current search
pattern.
Options
The Set Options screen enables you to modify two fields related to search
patterns. The Pattern-Matching Chars option enables you to specify
specially assigned characters for matching purposes. If you change the
default value of yes to no, HP EDIT does not recognize pattern-matching
characters and interprets a search pattern literally.
The Ignore Case option causes HP EDIT to interpret upper and lower case
patterns literally. If you change the default value of no to yes, HP
EDIT ignores case status when performing searches. A value of no for the
Pattern-Matching Chars option overrides a yes value for this option.
Pattern Matching Characters
The HP EDIT pattern-matching facility supports a set of seven optional
pattern-matching characters. If the Pattern-Matching Chars option is set
to the default value of yes, you can use these characters to provide
greater specificity within a search pattern. For instance, you may want
to search for the word The, but you may only want to search for
occurrences at the beginning of a line. HP EDIT provides a special
character for this purpose.
You can insert pattern-matching characters before, within, or after the
search pattern. You can also use more than one pattern-matching
character, or multiples of the same character, within the search pattern.
If you want HP EDIT to interpret a pattern-matching character literally,
you can precede the character with a back slash (\).
The available pattern-matching characters and their corresponding
definitions are as follows:
^ Matches the beginning of a line. If you use this character,
it must precede the search pattern. For instance, if you
wanted to only search for lines starting with the word The,
you would specify ^The as the search pattern.
$ Matches the end of a line. If you use this character, it must
follow the search pattern. For instance, if you wanted to
search for lines ending with periods, you would specify .$ as
the search pattern.
? Matches any single character. When a search command is
subsequently executed, any question marks within the search
pattern become "wild cards" or place holders for any character
including a question mark. For instance, to locate all
occurrences of then and than, you could specify th?n as the
search pattern. Note that the ? in this search pattern would
also match other possible characters, such as i in the word
thin.
[REV BEG]
@ Matches any string of zero or more characters.[REV END]
* Matches zero or more occurrences of the previous character in
the pattern. This can consist of another pattern-matching
character, such as ? . For instance, if you wanted to search
for all occurrences of the words son and soon, you could
specify so*n as the search pattern. This pattern could also
be used to find occurrences of sn. To exclude sn, you could
specify soo*n.
[REV BEG]
+ Matches one or more occurrences of the previous character.
This pattern-matching character may be used anywhere the the *
is appropriate.[REV END]
[ ] Matches any character from the set defined within brackets.
The pattern within the brackets can consist of a single
character, a series of single characters, or a range of
characters. For instance, if you wanted to search for a
capital letter, you would include [A-Z] in the search pattern.
To search for than and then but not thin, you could specify
th[ae]n as the search pattern.
[~ ] Matches any character not in the set within the brackets. The
pattern within the brackets can consist of a single character,
a series of single characters, or a range of characters. For
instance, if you want to search for all four-character strings
that start with th and end with n except for thin, you could
specify th[~i]n as the search pattern.
[REV BEG]
# Matches any single digit.[REV END]
Procedure
To define a search pattern:
1. Press the f key, or press the Search/Replace function key,
followed by the Define Search function key. HP EDIT displays
Search for ( ) : on the message line.
2. Type the search pattern including pattern-matching characters, if
desired.
3. Press Return. HP EDIT retains the prompt and typed search pattern
on the message line and returns the cursor to its previous
position before you executed the command. The search pattern is
now stored for subsequent search commands.
[REV BEG]
To define a search pattern using a character block:
1. Move the cursor to the point you want the search pattern to begin.
2. Press x, Mark Character Block Start.
3. Move the cursor to the character where you want the search pattern
to end.
4. Press f, Define Search Pattern. HP EDIT retains the selected
character block as the search pattern and stores it for subsequent
search commands.
[REV END]
Examples
To define a search pattern consisting of the letter A followed by a
non-digit:
1. Press the f key. HP EDIT displays the following prompt on the
message line:
Search for () : _
2. Type A[~0-9] at the cursor position. HP EDIT displays the prompt
and typed text on the message line:
Search for () : A[~0-9]_
3. Press Return.
To define a search pattern consisting of the letter A followed by any
four characters:
1. Press the f key. HP EDIT displays the following prompt on the
message line:
Search for () : _
2. Type the following text as shown:
Search for () : a????_
3. Press Return.
To define a search pattern consisting of any line ending with a pattern
beginning with the letter a, followed by zero or more letter b's,
followed by a single letter z:
1. Press the f key. HP EDIT displays the following prompt on the
message line:
Search for () : _
2. Type the following text as shown:
Search for () : ab*z$_
3. Press Return.
Related Commands
Define Replace Pattern
Define Replace Pattern From Text
Define Search Pattern From Text
Global Search And Replace Backward
Global Search And Replace Forward
Insert Replace Pattern
Insert Search Pattern
Search And Replace Backward
Search And Replace Forward
Search Backward
Search Forward
MPE/iX 5.0 Documentation