Method Regexp.PCRE2.MatchContext()->set_callout()

class Regexp.PCRE2.MatchContext

Method set_callout

void set_callout(function(CalloutBlock:int)|void callout)

Description

Set up a callout function to call at specified points during a matching operation.

Within a regular expression, (?C<arg>) indicates a point at which the external function is to be called. Different callout points can be identified by putting a number less than 256 after the letter C. The default value is zero. Alternatively, the argument may be a delimited string. The starting delimiter must be one of ` ' " ^ % # $ { and the ending delimiter is the same as the start, except for {, where the ending delimiter is }. If the ending delimiter is needed within the string, it must be doubled.

If the OPTION.AUTO_CALLOUT bit is set when a pattern is compiled, callouts are automatically inserted, all with number 255, before each item in the pattern except for immediately before or after an explicit callout.

Parameter callout

The function to call. If the function return zero, matching proceeds as normal. If the value is greater than zero, matching fails at the current point, but the testing of other matching possibilities goes ahead, just as if a lookahead assertion had failed. If the value is less than zero, the match is abandoned, and the matching function returns the negative value. In particular, ERROR.NOMATCH forces a standard "no match" failure. The error number ERROR.CALLOUT is reserved for use by callout functions; it will never be used by PCRE2 itself.