[ library(regex) | Reference Manual | Alphabetic Index ]

compile_pattern(+Pattern, +Options, -CompiledPattern)

Precompile a pattern for repeated use
Pattern
A string
Options
List of atoms
CompiledPattern
Output: a compiled pattern handle

Description

All matching predicates in this library accept either a regular expression in string form, or a precompiled regular expression. The matching predicates will execute faster if invoked with a precompiled pattern instead of the string. Whenever a pattern needs to be matched more than once, it will typically be more efficient to work with a precompiled pattern.

Options is a (possibly empty) list of atomic option names, as described in the library(regex) page. The options give here should be the same as the ones given to the matching-predicates later.

The space consumed by the compiled pattern will be automatically reclaimed on failure, or on garbage collection when no longer needed.

Modes and Determinism

Fail Conditions

None

Examples

    ?- compile_pattern("ab+a", [], C),
       match(C, "bbabbbaab", [], M1),
       match(C, "abacus", [], M2).

    C = 'HANDLE'(16'00025c60)
    M1 = "abbba"
    M2 = "aba"
    Yes
    

See Also

library(regex), match / 2, match / 3, match / 4, matchsub / 4, matchall / 4