Platforms to show: All Mac Windows Linux Cross-Platform
NSDataDetectorMBS class
Super class: NSRegularExpressionMBS
Type | Topic | Plugin | Version | macOS | Windows | Linux | iOS | Targets |
class | Cocoa Regular Expressions | MBS MacCocoa Plugin | 21.1 | ✅ Yes | ❌ No | ❌ No | ✅ Yes | All |
Currently the NSDataDetectorMBS class can match dates, addresses, links, phone numbers and transit information.
(links includes email addresses)
The results of matching content is returned as NSTextCheckingResultMBS objects. However, the NSTextCheckingResultMBS objects returned by NSDataDetectorMBS are different from those returned by the base class NSRegularExpressionMBS. Results returned by NSDataDetector will be of one of the data detectors types, depending on the type of result being returned, and they will have corresponding properties. For example, results of type NSTextCheckingTypeDate have a date, timeZone, and duration; results of type NSTextCheckingTypeLink have a URL, and so forth.
Subclass of the NSRegularExpressionMBS class.
- property checkingTypes as Integer
- 3 methods
- method Constructor(checkingTypes as Integer, byref error as NSErrorMBS)
- method Constructor(script as string, options as Integer, byref error as NSErrorMBS) Private
- method copy as NSDataDetectorMBS
- shared method dataDetectorWithTypes(checkingTypes as Integer, byref error as NSErrorMBS) as NSDataDetectorMBS
Super class NSRegularExpressionMBS
- event enumerateMatch(text as String, options as Integer, result as NSTextCheckingResultMBS, flags as Integer, byref stop as Boolean)
- 4 properties
- property Handle as Integer
- property numberOfCaptureGroups as Integer
- property options as Integer
- property pattern as String
- 10 methods
- method Constructor(script as string, options as Integer, byref error as NSErrorMBS)
- method copy as NSRegularExpressionMBS
- method enumerateMatches(text as string, options as Integer, range as NSRangeMBS = nil)
- method firstMatch(text as string, options as Integer, range as NSRangeMBS = nil) as NSTextCheckingResultMBS
- method matches(text as string, options as Integer, range as NSRangeMBS = nil) as NSTextCheckingResultMBS()
- method numberOfMatches(text as string, options as Integer, range as NSRangeMBS = nil) as Integer
- method rangeOfFirstMatch(text as string, options as Integer, range as NSRangeMBS = nil) as NSRangeMBS
- method replaceMatches(byref text as string, options as Integer, range as NSRangeMBS = nil, template as String) as Integer
- method replacementStringForResult(result as NSTextCheckingResultMBS, text as string, offset as Integer, template as String) as String
- method stringByReplacingMatches(text as string, options as Integer, range as NSRangeMBS = nil, template as String) as String
- 3 shared methods
- shared method escapedPatternForString(text as String) as String
- shared method escapedTemplateForString(text as String) as String
- shared method regularExpressionWithPattern(pattern as String, options as Integer, byref error as NSErrorMBS) as NSDataDetectorMBS
- 17 constants
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). |
This class has no sub classes.
Some methods using this class:
- NSRegularExpressionMBS.regularExpressionWithPattern(pattern as String, options as Integer, byref error as NSErrorMBS) as NSDataDetectorMBS
Some examples using this class:
Blog Entries
- MBS Xojo Plugins, version 24.1pr1
- Data Detectors as context menu
- XDC Anywhere - MBS Xojo Plugins
- MBS Xojo Plugin, June 2021 News
- News from the MBS Xojo Plugins Version 21.1
- Video about MBS Xojo Plugins 21.1
- MonkeyBread Software Releases the MBS Xojo Plugins in version 21.1
- MBS Xojo Plugins, version 21.1pr6
- Data Detectors for Xojo
Videos
- MBS Xojo Plugins 21.1
- XDC Anywhere - MBS Xojo Plugins
- MBS Xojo Videos - MBS Xojo Plugin, June 2021 News
Release notes
- Version 24.1
- Improved Data Detector example to include a contextual menu routine for showing actions based on NSDataDetectorMBS class.
- Version 21.1
- Added NSDataDetectorMBS and NSRegularExpressionMBS classes for macOS and iOS.
The items on this page are in the following plugins: MBS MacCocoa Plugin.
NSCustomTouchBarItemMBS - NSDateComponentsMBS