C 2
Using RegexKitLite
RegexKitLite 4.0 adds several new methods that take advantage of the new blocks language extension.
◼ - (BOOL)enumerateStringsMatchedByRegex:(NSString *)regex usingBlock:(void (^)(
NSInteger captureCount, NSString * const capturedStrings[captureCount],
const NSRange capturedRanges[captureCount], volatile BOOL * const stop))block;
◼ - (BOOL)enumerateStringsMatchedByRegex:(NSString *)regex
options:(RKLRegexOptions)options inRange:(NSRange)range error:(NSError **)error
enumerationOptions:(RKLRegexEnumerationOptions)enumerationOptions
usingBlock:(void (^)(NSInteger captureCount,
NSString * const capturedStrings[captureCount],
const NSRange capturedRanges[captureCount], volatile BOOL * const stop))block;
◼ - (BOOL)enumerateStringsSeparatedByRegex:(NSString *)regex usingBlock:(void (^)(
NSInteger captureCount, NSString * const capturedStrings[captureCount],
const NSRange capturedRanges[captureCount], volatile BOOL * const stop))block;
◼ - (BOOL)enumerateStringsSeparatedByRegex:(NSString *)regex
options:(RKLRegexOptions)options inRange:(NSRange)range error:(NSError **)error
enumerationOptions:(RKLRegexEnumerationOptions)enumerationOptions
usingBlock:(void (^)(NSInteger captureCount,
NSString * const capturedStrings[captureCount],
const NSRange capturedRanges[captureCount], volatile BOOL * const stop))block;
◼ - (NSString *)stringByReplacingOccurrencesOfRegex:(NSString *)regex
usingBlock:(NSString *(^)(NSInteger captureCount,
NSString * const capturedStrings[captureCount],
const NSRange capturedRanges[captureCount], volatile BOOL * const stop))block;
◼ - (NSString *)stringByReplacingOccurrencesOfRegex:(NSString *)regex
options:(RKLRegexOptions)options inRange:(NSRange)range error:(NSError **)error
enumerationOptions:(RKLRegexEnumerationOptions)enumerationOptions
usingBlock:(NSString *(^)(NSInteger captureCount,
NSString * const capturedStrings[captureCount],
const NSRange capturedRanges[captureCount], volatile BOOL * const stop))block;
◼ - (NSUInteger)replaceOccurrencesOfRegex:(NSString *)regex
usingBlock:(NSString *(^)(NSInteger captureCount,
NSString * const capturedStrings[captureCount],
const NSRange capturedRanges[captureCount], volatile BOOL * const stop))block;
◼ - (NSUInteger)replaceOccurrencesOfRegex:(NSString *)regex
options:(RKLRegexOptions)options inRange:(NSRange)range error:(NSError **)error
enumerationOptions:(RKLRegexEnumerationOptions)enumerationOptions
usingBlock:(NSString *(^)(NSInteger captureCount,
NSString * const capturedStrings[captureCount],
const NSRange capturedRanges[captureCount], volatile BOOL * const stop))block;
ere are no additional classes that supply the regular expression matching functionality, everything is ac-
complished with the two methods above. ese methods are added to the existing NSString class via an
Objective-C category extension. See RegexKitLite NSString Additions Reference (p. 47) for a complete list
of methods.
e real workhorse is the rangeOfRegex:options:inRange:capture:error: (p. 84) method. e receiver
of the message is an ordinary NSString class member that you wish to perform a regular expression match
on. e parameters of the method are a NSString containing the regular expression regex, any RKLRegexOp-
tions (p. 95) match options, the NSRange range of the receiver that is to be searched, the capture number
13
Using RegexKitLite
2010-04-18 – 4.0 © 2008-2010 John Engelhart, All Rights Reserved