Regular expressions (string, string1)
A regular expression in a FIND, CHANGE, or EXCLUDE command allows you to search for a string matching a basic or extended regular expression.
ISPF uses the IBM® C regcomp() — Compile regular expression and regexec() — Execute compiled regular expression functions to compile and execute a regular expression specified with a FIND, CHANGE, or EXCLUDE command. These are supported by the C runtime library and the C runtime library must be available.
00037 00871 01123 01156
00273 00875 01140 01157
00277 00924 01141 01158
00278 00930 01142 01160
00280 00933 01143 01165
00284 00935 01144 01364
00285 00937 01145 01371
00290 00939 01146 01388
00297 01025 01147 01390
00424 01026 01148 01399
00425 01027 01149 04971
00500 01047 01153 05123
00838 01112 01154 08482
00870 01122 01155 12712
ISPF uses the IBM C
setlocale function with LC_ALL to set the corresponding C locale.
This is done so that the special symbols (such as square brackets)
within the regular expression are correctly interpreted when the regcomp
function is used to compile the regular expression. If the TN3270 code page is not one of the listed code pages then the default C locale is used when compiling the regular expression. If a regular expression is encountered on a FIND, CHANGE, or EXCLUDE command that is specified in an Edit macro that is called from a batch Edit session (where no terminal is attached), code page 1047 is used.
The simplest form of regular expression is a string of characters with no special meaning.
The following characters do have a special meaning; they are used to form extended regular expressions:
- Symbol
- Description
- . (period)
- The period symbol matches any one character except the terminal
newline character.
For example, the regular expression
d.gmatchesdig
,dug
, anddog
, but notdg
, though it matchesdgg
. - * (asterisk)
- The asterisk symbol matches zero or more instances of the previous
character.
For example, the regular expression
he*athmatcheshath
andheath
and (if it exists)heeath
. - ? (question mark)
- The question mark symbol matches zero or one instance of the previous
character.
For example, the regular expression
behaviou?rmatchesbehaviour
andbehavior
. - + (plus)
- The plus symbol matches one or more instances of the previous
character.
For example, the regular expression
south+ernmatchessouthern
andsouthhern
, but notsoutern
. (If you also wanted a match forsoutern
, usesouth*ernas the regular expression.) - | (vertical bar)
- The vertical bar symbol acts as an OR operator and matches the
values to the left and right of the vertical bar.
For example, the regular expression
Jack|JillmatchesJack
andJill
. - \ (backslash)
- The backslash symbol acts as an escape sequence. Use it when you
want search for a regular expression symbol. The backslash character
immediately precedes the symbol in the expression.
For example, the regular expression
a.\+.bmatches the stringa + b
. - [string]
- A string within square brackets matches any one of the characters
in string.
For example, the regular expression
d[iu]gmatchesdig
anddug
, but notdog
. - [character-character]
- The hyphen symbol, within square brackets, means through.
It fills in the intervening characters according to the current collating
sequence. For example, [a-z] can be equivalent to [abc...xyz] or,
with a different collating sequence, it can be equivalent to [aAbBcC...xXyYzZ].
For example, the regular expression
m[a-z]pmatchesmap
andmop
, but notm9p
, since 9 is not in the range a to z. - [^string]
- The caret symbol, when the first character inside square brackets,
negates the following characters within the square brackets.
For example, the regular expression
d[^iu]gmatchesdog
, but notdig
ordug
. - {m} {m,u} {m,}
- Integer values enclosed in {} indicate the number of times to
apply the preceding regular expression. m is the
minimum number, and u is the maximum number. {m}
indicates an exact number of times to apply the regular expression.
{m,u} indicates a range of instances.
{m,} indicates that there is a minimum, but no
maximum.
For example:
m[eaiy]{2}nmatchesmain
,mien
andmean
, but it does not matchman
, because there is only one instance of the letters in the square brackets. Nor does it matchmayan
, because this has three instances of the letters in the square brackets.[0-9][a-z]{2,3}[0-9]matches7ab5
and4abc3
, but not7b5
, nor4abcd3
.[0-9][a-z]{2,}[0-9]matches4ab3
,4abc3
,4abcd3
, and so on, but not4a3
.
- (expression)
- Used to group parts of the expression into sub-expressions. This
can be used to limit an operator to a sub-expression.
For example, the regular expression
z/OS.((1\.1[0-3])|(2\.[1-2]))matchesz/OS® 1.13
andz/OS 2.1
.
Regular expressions cannot be used for string2 for a CHANGE command.