Compile Method (REGEX)
The Compile method is used to compile and store.a regular expression in the associated PL/B REGEX object. This method uses the following format:
|
|
|
|
|
|
|
|
Where:
label
Optional. A Program Execution Label.
object
Required. A REGEX object previously declared.
return
Optional. A Numeric Variable that returns a one for success or zero for failure.
pattern
Required. A Character String Variable or literal that specifies a valid regular expression.
options
Optional. A decimal number or Numeric Variable that has a bit mask value described below.
Flags Affected: EOS, OVER, ZERO
Notes:
If the value returned is zero, the ZERO Condition Flag is set.
The OVER flag is set TRUE if the 'return' variable is too small and cannot contain the 'return' value without being truncated. Otherwise, the OVER flag is set to FALSE.
The EOS flag is always cleared.
The {pattern} parameter contains the regular expression to be compiled.
If successful the pattern is stored in the object for later compiled calls.
The object's last-match cache is cleared.
The {options} bit mask values found in plbmeth.inc are defined as follows:
|
Equate |
Value |
Description |
|
$REGEX_OPT_NOCASE |
1 |
Case-insensitive (ASCII A-Z only) |
|
$REGEX_OPT_MULTILINE |
8 |
^ and $ also match at line breaks |
|
$REGEX_OPT_DOTALL |
16 |
. also matches CR and LF |
|
$REGEX_OPT_NOTEMPTY |
32 |
Reject empty (zero-length) matches |
The {return} value is one when the pattern compiled successfully and zero when the compile failed
Patterns that fail to compile include an unclosed group or class, an empty class [], a quantifier with nothing to repeat, a quantifier on an anchor ($+, ^*), a{5,2}, a{255}, {,n}, more groups than the limit, an unknown POSIX class, an invalid \x or octal escape, a trailing backslash, a reference to a missing group, and a pattern too large. Also a class used as a range endpoint, such as [a-\d] or [[:digit:]-z] will fail to compile.
Example 1:
Example 2:
See Also: Method Syntax, REGEX, Regular Expression Support
![]() |