PXRegexPattern Class Reference
| Inherits from | NSObject |
| Conforms to | NSCopying |
| Declared in | PXRegexPattern.h PXRegexPattern.m |
Overview
A PXRegexPattern creates a compiled regex string from the given info. This is used to find matches later. A PXRegexPattern object is immutable.
Example:
PXRegexPattern *pattern = [[PXRegexPattern alloc] initWithRegex:@"^(\\w+)\\s(.*)$"];
PXRegexMatcher *matcher = [[PXRegexMatcher alloc] initWithPattern:pattern string:@"person name:Steve age:56"];
[pattern release];
// If there are lots of potential matches, a while loop should be used.
if ([matcher next])
{
NSLog (@"%@", [matcher groupAtIndex:0]); // @"person name:Steve age:56"
NSLog (@"%@", [matcher groupAtIndex:1]); // @"person"
NSLog (@"%@", [matcher groupAtIndex:2]); // @"name:Steve age:56"
}
[matcher release];
Tasks
-
flagsA list of
propertyPXRegexPatternFlagflags that will define how the regex is compiled. -
regexThe compiled regex pattern.
property -
capturingGroupCountReturns the number of capturing groups in this matcher’s pattern.
property -
– matcherWithInput:Creates a new PXRegexMatcher object containing all information needed to match your strings with the compiled regex.
-
+ patternWithRegex:flags:Creates a regex pattern.
-
+ quoteString:Not yet implemented
-
+ splitString:Invokes splitString:limit: using 0 as the limit.
-
+ splitString:limit:Not yet implemented
Properties
capturingGroupCount
Returns the number of capturing groups in this matcher’s pattern.
@property (nonatomic, readonly) unsigned capturingGroupCountDiscussion
Group zero denotes the entire pattern by convention. It is not included in this count.
Declared In
PXRegexPattern.hClass Methods
patternWithRegex:flags:
Creates a regex pattern.
+ (PXRegexPattern *)patternWithRegex:(NSString *)regex flags:(unsigned)flagsParameters
- flags
The flags explaining how to compile the regex.
- pattern
The regex to compile. If regex is not
nilthen it immediately compiles the regex.
Return Value
The resulting, autoreleased, @PXRegexPattern object.
Declared In
PXRegexPattern.mquoteString:
Not yet implemented
+ (NSString *)quoteString:(NSString *)inputDeclared In
PXRegexPattern.msplitString:
Invokes splitString:limit: using 0 as the limit.
+ (NSArray *)splitString:(NSString *)inputDeclared In
PXRegexPattern.mInstance Methods
matcherWithInput:
Creates a new PXRegexMatcher object containing all information needed to match your strings with the compiled regex.
- (PXRegexMatcher *)matcherWithInput:(NSString *)inputParameters
- string
The string to find matches for.
Return Value
The new PXRegexMatcher object.
Declared In
PXRegexPattern.m