Platforms to show: All Mac Windows Linux Cross-Platform

PCRE2CompilerMBS class

Type Topic Plugin Version macOS Windows Linux iOS Targets
class Regular Expressions MBS RegEx Plugin 22.2 ✅ Yes ✅ Yes ✅ Yes ✅ Yes All
The class for compiling regular expression patterns into code.
Example
Var Compiler As New PCRE2CompilerMBS

// find numbers
compiler.Pattern = "(\d+)([$€£]?)"

Var code As PCRE2CodeMBS = Compiler.Compile

// prepare reuable match object
Var Match As New PCRE2MatchDataMBS(code)

// now run a match
Var Text As String = "Täst 1234€ Case"
Var n As Integer = code.Match(Text, match)

// get result found
Var TotalSubString As String = match.SubString(0)
Var SubString1 As String = match.SubString(1)
Var SubString2 As String = match.SubString(2)

break // see debugger

Constants

Constant Value Description
kOptimizationAutoPossess 64 Enable/disable "auto-possessification" of variable quantifiers such as * and +. This optimization, for example, turns a+b into a++b in order to avoid backtracks into a+ that can never be successful. However, if callouts are in use, auto-possessification means that some callouts are never taken. You can disable this optimization if you want the matching functions to do a full, unoptimized search and run all the callouts.

BSR

Constant Value Description
kBSRanyCRLF 2 CR, LF, or CRLF only
kBSRUnicode 1 Unicode line endings

New Line Character

Constant Value Description
kNewLineAny 4 Any Unicode newline sequence.
kNewLineAnyCRLF 5 CR, LF or CRLF.
kNewLineCR 1 Carriage return only
kNewLineCRLF 3 CR followed by LF only
kNewLineLF 2 Linefeed only
kNewLineNul 6 The NUL character (binary zero)

Optimization Flags

Constant Value Description
kOptimizationAutoPossessOff 65 Enable/disable "auto-possessification" of variable quantifiers such as * and +. This optimization, for example, turns a+b into a++b in order to avoid backtracks into a+ that can never be successful. However, if callouts are in use, auto-possessification means that some callouts are never taken. You can disable this optimization if you want the matching functions to do a full, unoptimized search and run all the callouts.
kOptimizationDotstarAnchor 66 Enable/disable an optimization that is applied when .* is the first significant item in a top-level branch of a pattern, and all the other branches also start with .* or with \A or \G or ^. Such a pattern is automatically anchored if PCRE2_DOTALL is set for all the .* items and PCRE2_MULTILINE is not set for any ^ items. Otherwise, the fact that any match must start either at the start of the subject or following a newline is remembered. Like other optimizations, this can cause callouts to be skipped. more
kOptimizationDotstarAnchorOff 67 Enable/disable an optimization that is applied when .* is the first significant item in a top-level branch of a pattern, and all the other branches also start with .* or with \A or \G or ^. Such a pattern is automatically anchored if PCRE2_DOTALL is set for all the .* items and PCRE2_MULTILINE is not set for any ^ items. Otherwise, the fact that any match must start either at the start of the subject or following a newline is remembered. Like other optimizations, this can cause callouts to be skipped. more
kOptimizationFull 1 Enable all optional performance optimizations. This is the default value.
kOptimizationNone 0 Disable all optional performance optimizations.
kOptimizationStartOptimize 68 Enable/disable optimizations which cause matching functions to scan the subject string for specific code unit values before attempting a match. For example, if it is known that an unanchored match must start with a specific value, the matching code searches the subject for that value, and fails immediately if it cannot find it, without actually running the main matching function. This means that a special item such as (*COMMIT) at the start of a pattern is not considered until after a suitable starting point for the match has been found. Also, when callouts or (*MARK) items are in use, these "start-up" optimizations can cause them to be skipped if the pattern is never actually used. The start-up optimizations are in effect a pre-scan of the subject that takes place before the pattern is run. more
kOptimizationStartOptimizeOff 69 Enable/disable optimizations which cause matching functions to scan the subject string for specific code unit values before attempting a match. For example, if it is known that an unanchored match must start with a specific value, the matching code searches the subject for that value, and fails immediately if it cannot find it, without actually running the main matching function. This means that a special item such as (*COMMIT) at the start of a pattern is not considered until after a suitable starting point for the match has been found. Also, when callouts or (*MARK) items are in use, these "start-up" optimizations can cause them to be skipped if the pattern is never actually used. The start-up optimizations are in effect a pre-scan of the subject that takes place before the pattern is run. more

This class has no sub classes.

Blog Entries

Xojo Developer Magazine

Release notes

  • Version 26.4
    • Added SetOptimize method to PCRE2CompilerMBS class and related constants.
    • Added TurkishCasing, NeverCallout, EffectiveLinksize, CaselessRestrict, AltExtendedClass properties to PCRE2CompilerMBS class.

Some examples using this class:

Some related classes:


The items on this page are in the following plugins: MBS RegEx Plugin.


PCRE2CodeMBS   -   PCRE2ExceptionMBS


The biggest plugin in space...