Test Method (REGEX)
The Test method is used to check for a matching substring using a provided.regular expression for a 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 one when a match found or zero otherwise.
pattern
Required. A Character String Variable or literal that specifies a valid regular expression.
text
Required. A Character String Variable or literal that specifies the text to examine.
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 and used.
The {text} parameter contains the character string to be searched.
The {return} value is one when a match found or zero otherwise.
This is a one-shot evaluation and does not replace the object's compiled pattern.
A zero-length match counts as a match.
If no matches are found the GetMatch method will return an empty string.
If a match is found the GetMatch method will return the match found.
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. |
Example 1:
See Also: Method Syntax, REGEX, Regular Expression Support
![]() |