regexcomp, regexexec, createMatchArray
Purpose: These functions provide access to the regular expression library pcre (1 2). Using regexcomp() a regular expression pattern can be compiled for later use. regexexec() uses a compiled regular expression (maybe several times) to match strings to this pattern. The exact syntax and semantics of the regular expressions is documented with the pcre library. The regexexec() function returns an array of matching positions. It contains start and end positions for each parenthesized subexpressions within the regular expression. This array must be created before the first call with the createMatchArray() function. Return Values: When successful, regexcomp() returns a compiled representation of the regular expression pattern (type tPcre). If regexcomp() fails, the compilation aborts with an error message. regexexec() returns an integer denoting how many elements of matcharray are used if the regular expression matches the string, leaving the matching positions in matcharray, and returns null if not. createMatchArray() returns a tuple of tuples. There are two array tuples, each of size size. The two arrays are fields of the main tuple with fieldnames start and end. The array fields of both arrays are initialized with integer 0s. The regexexec() function puts start position of each parenthesized subexpression into the start array and the corresponding end positions into the end array.
Position Argument: The position argument must be an integer variable denoting the position in the string where the search starts.Flags Argument: The functions regexcomp() and regexexec() have an additional argument flags. It must be a string containing a comma or white space seperated list of flags. The following flags are supported and are documented in the pcre documentation. ANCHORED, BSR_ANYCRLF, BSR_UNICODE, CASELESS, DOLLAR_ENDONLY, DOTALL, DUPNAMES, EXTENDED, EXTRA, FIRSTLINE, JAVASCRIPT_COMPAT, MULTILINE, NEWLINE_CR, NEWLINE_LF, NEWLINE_CRLF, NEWLINE_ANYCRLF, NEWLINE_ANY, NO_AUTO_CAPTURE, NO_UTF8_CHECK, UNGREEDY, UTF8 ANCHORED, NEWLINE_CR, NEWLINE_LF, NEWLINE_CRLF, NEWLINE_ANYCRLF, NEWLINE_ANY, NOTBOL, NOTEOL, NOTEMPTY, NO_START_OPTIMIZE, NO_UTF8_CHECK, PARTIAL
Example:
Example:
Example:
Example:
See Also: indexRE(), indexCaseRE(), containsRE(), containsCaseRE(), substRE(), substallRE(). © 1996-2023 H.E.I. All Rights Reserved. |
![]() |