NSData RegexKit Additions Reference
PCRE7.6
AvailabilityAvailable in Mac OS X v10.4 or later.
Overview
RKCompileOption Requirements
Unlike the other Foundation additions, the NSData additions do not require and do not set the RKCompileUTF8 and RKCompileNoUTF8Check compile option flags due to the fact that NSData objects represent raw byte buffers.
Important:
Some Unicode regular expression escapes sequences are not available unless
RKCompileUTF8 is set. If you require this functionality, or the data contained by the
NSData object is
UTF8 Unicode data, you will need to instantiate a
RKRegex with the
RKCompileUTF8 option set.
Specifying a Regular Expression
When specifying a regular expression, the regular expression can be either a RKRegex object or a NSString containing the text of a regular expression. When specified as a NSString, as determined by sending isKindOfClass:, the receiver will convert the string to a RKRegex object via regexWithRegexString:options:.
Determining if an Object Matches a Regular Expression
Objects are sent isMatchedByRegex: to determine whether or not they are matched by the specified regular expression.
Tasks
Instance Methods
Returns a Boolean value that indicates whether the receiver is matched by aRegex.
- (BOOL)isMatchedByRegex:(id)aRegex;
Returns a Boolean value that indicates whether the receiver is matched by aRegex within range.
- (BOOL)isMatchedByRegex:(id)aRegex inRange:(const NSRange)range;
Returns the range of the first occurrence within the receiver of aRegex.
- (NSRange)rangeOfRegex:(id)aRegex;
A NSRange structure giving the location and length of the first match of aRegex in the receiver. Returns {NSNotFound, 0} if the receiver is not matched by aRegex.
Returns the range of aRegex capture number capture for the first match within range of the receiver.
- (NSRange)rangeOfRegex:(id)aRegex inRange:(const NSRange)range capture:(const
RKUInteger)capture;
A NSRange structure giving the location and length of aRegex capture number capture for the first match within range of the receiver. Returns {NSNotFound, 0} if the receiver is not matched by aRegex.
Returns a pointer to an array of NSRange structures of the capture subpatterns of aRegex for the first match in the receiver.
- (NSRange *)rangesOfRegex:(id)aRegex;
Returns a pointer to an array of NSRange structures of the capture subpatterns of aRegex for the first match in the receiver, or NULL if aRegex does not match.
Returns a pointer to an array of NSRange structures of the capture subpatterns of aRegex for the first match in the receiver within range.
- (NSRange *)rangesOfRegex:(id)aRegex inRange:(const NSRange)range;
Returns a pointer to an array of NSRange structures of the capture subpatterns of aRegex for the first match in the receiver within range, or NULL if aRegex does not match.
Returns a NSData that contains the bytes of the first match by aRegex.
- (NSData *)subdataByMatching:(id)aRegex;
Returns a NSData that contains the bytes of the first match by aRegex within range.
- (NSData *)subdataByMatching:(id)aRegex inRange:(const NSRange)range;