Platforms to show: All Mac Windows Linux Cross-Platform

NSRegularExpressionMBS class

Type Topic Plugin Version macOS Windows Linux iOS Targets
class Cocoa Regular Expressions MBS MacCocoa Plugin 21.1 ✅ Yes ❌ No ❌ No ✅ Yes All
Function: An immutable representation of a compiled regular expression that you apply to Unicode strings.
Notes:
The fundamental matching method for NSRegularExpressionMBS is a Block iterator method that allows clients to supply a Block object which will be invoked each time the regular expression matches a portion of the target string. There are additional convenience methods for returning all the matches as an array, the total number of matches, the first match, and the range of the first match.

An individual match is represented by an instance of the NSTextCheckingResultMBS class, which carries information about the overall matched range (via its range property), and the range of each individual capture group (via the rangeAtIndex: method). For basic NSRegularExpression objects, these match results will be of type NSTextCheckingTypeRegularExpression, but subclasses may use other types.

see also
https://developer.apple.com/documentation/foundation/nsregularexpression

Feedback, Comments & Corrections

Matching Options

Constant Value Description
MatchingAnchored 4 Specifies that matches are limited to those at the start of the search range. See enumerateMatches for a description of the constant in context.
MatchingReportCompletion 2 Call the Block once after the completion of any matching. This option has no effect for methods other than enumerateMatches. See enumerateMatches for a description of the constant in context.
MatchingReportProgress 1 Call the Block periodically during long-running match operations. This option has no effect for methods other than enumerateMatches. See enumerateMatches for a description of the constant in context.
MatchingWithoutAnchoringBounds 16 Specifies that ^ and $ will not automatically match the beginning and end of the search range, but will still match the beginning and end of the entire string. This constant has no effect if the search range contains the entire string. See enumerateMatches for a description of the constant in context.
MatchingWithTransparentBounds 8 Specifies that matching may examine parts of the string beyond the bounds of the search range, for purposes such as word boundary detection, lookahead, etc. This constant has no effect if the search range contains the entire string. See enumerateMatches for a description of the constant in context.

Progress

Constant Value Description
MatchingCompleted 2 Set when the Block is called after matching has completed.
MatchingHitEnd 4 Set when the current match operation reached the end of the search range.
MatchingInternalError 16 Set when matching failed due to an internal error.
MatchingProgress 1 Set when the Block is called to report progress during a long-running match operation.
MatchingRequiredEnd 8 Set when the current match depended on the location of the end of the search range.

Options

Constant Value Description
RegularExpressionAllowCommentsAndWhitespace 2 Ignore whitespace and #-prefixed comments in the pattern.
RegularExpressionAnchorsMatchLines 16 Allow ^ and $ to match the start and end of lines.
RegularExpressionCaseInsensitive 1 Match letters in the pattern independent of case.
RegularExpressionDotMatchesLineSeparators 8 Allow . to match any character, including line separators.
RegularExpressionIgnoreMetacharacters 4 Treat the entire pattern as a literal string.
RegularExpressionUseUnicodeWordBoundaries 64 Use Unicode TR#29 to specify word boundaries (otherwise, traditional regular expression word boundaries are used).
RegularExpressionUseUnixLineSeparators 32 Treat only \n as a line separator (otherwise, all standard line separators are used).

Sub classes:

Some properties using for this class:

Blog Entries


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


NSRectMBS   -   NSResponderMBS

The biggest plugin in space...




Links
MBS Xojo tutorial videos

Start Chat