Platforms to show: All Mac Windows Linux Cross-Platform
Back to PCRE2CodeMBS class.
PCRE2CodeMBS.Constructor Private
Type | Topic | Plugin | Version | macOS | Windows | Linux | iOS | Targets |
method | Regular Expressions | MBS RegEx Plugin | 22.2 | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes | All |
PCRE2CodeMBS.Copy(withTables as boolean = false) as PCRE2CodeMBS
Type | Topic | Plugin | Version | macOS | Windows | Linux | iOS | Targets |
method | Regular Expressions | MBS RegEx Plugin | 22.2 | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes | All |
Without a subsequent call to JITCompile(), the copy can be used only for non-JIT matching. The pointer to the character tables is copied, not the tables themselves (unless withTables is true).
PCRE2CodeMBS.Infos as PCRE2CodeInfoMBS()
Type | Topic | Plugin | Version | macOS | Windows | Linux | iOS | Targets |
method | Regular Expressions | MBS RegEx Plugin | 22.2 | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes | All |
Useful to debug the pattern.
PCRE2CodeMBS.JITCompile(Flags as Integer = 1)
Type | Topic | Plugin | Version | macOS | Windows | Linux | iOS | Targets |
method | Regular Expressions | MBS RegEx Plugin | 22.2 | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes | All |
If the just-in-time compiler is available, further processes a compiled pattern into machine code that executes much faster than the Match() interpretive matching function.
Some examples using this method:
PCRE2CodeMBS.Match(Text as String, matchData as PCRE2MatchDataMBS, StartOffsetCharacters as Integer = 0, MatchContext as PCRE2MatchContextMBS = nil) as Integer
Type | Topic | Plugin | Version | macOS | Windows | Linux | iOS | Targets |
method | Regular Expressions | MBS RegEx Plugin | 22.2 | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes | All |
It returns offsets to what it has matched and to captured substrings via the matchData object. The return from Match() is one more than the highest numbered capturing pair that has been set (for example, 1 if there are no captures), zero if the vector of offsets is too small.
Raises exception in case of error.
A match context is needed only if you want to:
- Set up a callout function
- Set a matching offset limit
- Change the heap memory limit
- Change the backtracking match limit
- Change the backtracking depth limit
- Set custom memory management specifically for the match
StartOffsetCharacters is optional to start at a specific character in the text.
See also:
PCRE2CodeMBS.Match(Text as String, StartOffsetCharacters as Integer = 0, MatchContext as PCRE2MatchContextMBS = nil) as PCRE2MatchDataMBS
Type | Topic | Plugin | Version | macOS | Windows | Linux | iOS | Targets |
method | Regular Expressions | MBS RegEx Plugin | 22.2 | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes | All |
Performs match and returns the new PCRE2MatchDataMBS object.
Returns nil in case nothing is found.
See also:
PCRE2CodeMBS.MatchAll(Text as String, StartOffsetCharacters as Integer = 0, MatchContext as PCRE2MatchContextMBS = nil) as PCRE2MatchDataMBS()
Type | Topic | Plugin | Version | macOS | Windows | Linux | iOS | Targets |
method | Regular Expressions | MBS RegEx Plugin | 22.2 | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes | All |
This does a loop to go over text from start to end to match the pattern as often as it fits.
We try to avoid endless loops.
Returns an array with PCRE2MatchDataMBS objects, one for each match.
Some examples using this method:
PCRE2CodeMBS.Matches(Text as String, StartOffsetCharacters as Integer = 0, MatchContext as PCRE2MatchContextMBS = nil) as PCRE2IteratorMBS
Type | Topic | Plugin | Version | macOS | Windows | Linux | iOS | Targets |
method | Regular Expressions | MBS RegEx Plugin | 22.2 | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes | All |
Returns the iterator, so you can use it with for each loop.
May raie an error if something goes wrong.
PCRE2CodeMBS.Names as String()
Type | Topic | Plugin | Version | macOS | Windows | Linux | iOS | Targets |
method | Regular Expressions | MBS RegEx Plugin | 22.2 | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes | All |
PCRE2CodeMBS.SerializeEncode as String
Type | Topic | Plugin | Version | macOS | Windows | Linux | iOS | Targets |
method | Regular Expressions | MBS RegEx Plugin | 22.2 | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes | All |
Note that this is not an abstract format like Java or .NET. Conversion of the byte stream back into usable compiled patterns can only happen on a host that is running the same version of PCRE2, with the same code unit width, and the host must also have the same endianness, pointer width and size_t type.
PCRE2CodeMBS.Substitute(Text as String, Replacement as String, matchData as PCRE2MatchDataMBS = nil, StartOffsetCharacters as Integer = 0, MatchContext as PCRE2MatchContextMBS = nil) as String
Type | Topic | Plugin | Version | macOS | Windows | Linux | iOS | Targets |
method | Regular Expressions | MBS RegEx Plugin | 22.2 | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes | All |
It then makes a copy of the subject, substituting a replacement string for what was matched.
Text: The subject string
Replacement: the replacement string
matchData: The match data block, or is nil if you don't need the result.
StartOffsetCharacters: Offset in the subject at which to start matching.
MatchContext: A match context, or nil.
A match data block is needed only if you want to inspect the data from the final match that is returned in that block or if SubstituteMatched is set. A match context is needed only if you want to:
- Set up a callout function
- Set a matching offset limit
- Change the backtracking match limit
- Change the backtracking depth limit
- Set custom memory management in the match context
Raises exception in case of error.
The options are controlled via properties:
Anchored | Match only at the first position |
EndAnchored | Pattern can match only at end of subject |
NotBOL | Subject string is not the beginning of a line |
NotEOL | Subject string is not the end of a line |
NotEmpty | An empty string is not a valid match |
NotEmptyAtStart | An empty string at the start of the subject is not a valid match |
NoJit | Do not use JIT matching |
NoUTFCheck | Do not check the subject for UTF validity (only relevant if UTF was set at compile time) |
PartialHard | Return PCRE2_ERROR_PARTIAL (-2) for a partial match even if there is a full match |
PartialSoft | Return PCRE2_ERROR_PARTIAL (-2) for a partial match if no full matches are found. |
PCRE2CodeMBS.SubstringNumberFromName(Name as String) as Integer
Type | Topic | Plugin | Version | macOS | Windows | Linux | iOS | Targets |
method | Regular Expressions | MBS RegEx Plugin | 22.2 | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes | All |
If the string is not found, you receive a negative value.
For other errors, we raise an exception.
The items on this page are in the following plugins: MBS RegEx Plugin.