NSObject RegexKit Additions Reference

Extends by categoryNSObject
RegexKit0.6.0 Release Notes
PCRE7.6
AvailabilityAvailable in Mac OS X v10.4 or later.
Declared in
  • RegexKit/NSObject.h
Overview

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:.

Important:
The method will raise NSInvalidArgumentException if the regular expression is nil. If passed as a NSString, the method will raise RKRegexSyntaxErrorException if the regular expression is not valid.

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

Identifying and Comparing Objects
Identifying Matches in an Array
Identifying Matches in a Set

Instance Methods

Returns any regular expression from regexArray that matches the receiver.
- (RKRegex *)anyMatchingRegexInArray:(NSArray *)regexArray;
Parameters
  • regexArray
    A NSArray containing either regular expression strings or RKRegex objects.
Discussion
Equivalent to anyMatchingRegexInArray:library:options:error: using regexArray with RKRegexPCRELibrary for library and (RKCompileUTF8 | RKCompileNoUTF8Check) for libraryOptions.
Return Value
Returns one of the regular expressions from regexArray that matches the receiver, or NULL if the receiver is not matched by any of the regular expressions or an error occurs. The object returned is chosen at the receiver's convenience- the selection is not guaranteed to be random.
Returns any regular expression from regexArray that matches the receiver using the regular expression library and libraryOptions, setting the optional error parameter if an error occurs.
- (RKRegex *)anyMatchingRegexInArray:(NSArray *)regexArray library:(NSString *)library options:(RKCompileOption)libraryOptions error:(NSError **)error;
Discussion
regexArray may contain either regular expression strings or RKRegex objects. See Regular Expression Libraries for a list of valid library constants. If information about any errors is not required, error may be set to NULL.
Return Value
Returns one of the regular expressions from regexArray that matches the receiver, or NULL if the receiver is not matched by any of the regular expressions or an error occurs. The object returned is chosen at the receiver's convenience- the selection is not guaranteed to be random.
Returns any regular expression from regexSet that matches the receiver.
- (RKRegex *)anyMatchingRegexInSet:(NSSet *)regexSet;
Parameters
  • regexSet
    A NSSet containing either regular expression strings or RKRegex objects.
Discussion
Equivalent to anyMatchingRegexInSet:library:options:error: using regexArray with RKRegexPCRELibrary for library and (RKCompileUTF8 | RKCompileNoUTF8Check) for libraryOptions.
Return Value
Returns one of the regular expressions from regexSet that matches the receiver, or NULL if the receiver is not matched by any of the regular expressions or an error occurs. The object returned is chosen at the receiver's convenience- the selection is not guaranteed to be random.
Returns any regular expression from regexSet that matches the receiver using the regular expression library and libraryOptions, setting the optional error parameter if an error occurs.
- (RKRegex *)anyMatchingRegexInSet:(NSSet *)regexSet library:(NSString *)library options:(RKCompileOption)libraryOptions error:(NSError **)error;
Discussion
See Regular Expression Libraries for a list of valid library constants. If information about any errors is not required, error may be set to NULL.
Return Value
regexSet may contain either regular expression strings or RKRegex objects. Returns one of the regular expressions from regexSet that matches the receiver, or NULL if the receiver is not matched by any of the regular expressions or an error occurs. The object returned is chosen at the receiver's convenience- the selection is not guaranteed to be random.
Returns the first regular expression from regexArray that matches the receiver.
- (RKRegex *)firstMatchingRegexInArray:(NSArray *)regexArray;
Parameters
  • regexArray
    A NSArray containing either regular expression strings or RKRegex objects.
Discussion
Equivalent to firstMatchingRegexInArray:library:options:error: using regexArray with RKRegexPCRELibrary for library and (RKCompileUTF8 | RKCompileNoUTF8Check) for libraryOptions.
Return Value
Returns the first regular expression from regexArray that matches the receiver, or NULL if the receiver is not matched by any of the regular expressions or an error occurs.
Returns the first regular expression from regexArray that matches the receiver using the regular expression library and libraryOptions, setting the optional error parameter if an error occurs.
- (RKRegex *)firstMatchingRegexInArray:(NSArray *)regexArray library:(NSString *)library options:(RKCompileOption)libraryOptions error:(NSError **)error;
Discussion
regexArray may contain either regular expression strings or RKRegex objects. See Regular Expression Libraries for a list of valid library constants. If information about any errors is not required, error may be set to NULL.
Return Value
Returns the first regular expression from regexArray that matches the receiver, or NULL if the receiver is not matched by any of the regular expressions or an error occurs.
Returns a Boolean value that indicates whether the receiver is matched by any regular expression in regexArray.
- (BOOL)isMatchedByAnyRegexInArray:(NSArray *)regexArray;
Parameters
  • regexArray
    A NSArray containing either regular expression strings or RKRegex objects.
Discussion
Equivalent to isMatchedByAnyRegexInArray:library:options:error: using regexArray with RKRegexPCRELibrary for library and (RKCompileUTF8 | RKCompileNoUTF8Check) for libraryOptions.
Return Value
Returns YES if the receiver is matched by any regular expression in regexArray, NO otherwise.
Returns a Boolean value that indicates whether the receiver is matched by any regular expression in regexArray using the regular expression library and libraryOptions, setting the optional error parameter if an error occurs.
- (BOOL)isMatchedByAnyRegexInArray:(NSArray *)regexArray library:(NSString *)library options:(RKCompileOption)libraryOptions error:(NSError **)error;
Discussion
regexArray may contain either regular expression strings or RKRegex objects. See Regular Expression Libraries for a list of valid library constants. If information about any errors is not required, error may be set to NULL.
Return Value
Returns YES if the receiver is matched by any regular expression in regexArray, NO otherwise.
Returns a Boolean value that indicates whether the receiver is matched by any regular expression in regexSet.
- (BOOL)isMatchedByAnyRegexInSet:(NSSet *)regexSet;
Parameters
  • regexSet
    A NSSet containing either regular expression strings or RKRegex objects.
Discussion
Equivalent to isMatchedByAnyRegexInSet:library:options:error: using regexArray with RKRegexPCRELibrary for library and (RKCompileUTF8 | RKCompileNoUTF8Check) for libraryOptions.
Return Value
Returns YES if the receiver is matched by any regular expression in regexSet, NO otherwise.
Returns a Boolean value that indicates whether the receiver is matched by any regular expression in regexSet using the regular expression library and libraryOptions, setting the optional error parameter if an error occurs.
- (BOOL)isMatchedByAnyRegexInSet:(NSSet *)regexSet library:(NSString *)library options:(RKCompileOption)libraryOptions error:(NSError **)error;
Discussion
regexSet may contain either regular expression strings or RKRegex objects. See Regular Expression Libraries for a list of valid library constants. If information about any errors is not required, error may be set to NULL.
Return Value
Returns YES if the receiver is matched by any regular expression in regexSet, NO otherwise.
Returns a Boolean value that indicates whether the receiver is matched by aRegex.
- (BOOL)isMatchedByRegex:(id)aRegex;
Parameters
  • aRegex
    A regular expression string or RKRegex object.
Discussion
Invokes isMatchedByRegex: on the NSString returned by the receivers description.
Return Value
Returns YES if the receiver is matched by aRegex, NO otherwise.
 
RegexKit project hosted by: