-
Notifications
You must be signed in to change notification settings - Fork 134
/
ICUMatcher.h
127 lines (109 loc) · 4.06 KB
/
ICUMatcher.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
//
// ICUMatcher.h
// CocoaICU
//
// Created by Aaron Evans on 11/29/06.
// Copyright 2006 Aaron Evans. All rights reserved.
//
#import <Cocoa/Cocoa.h>
@class ICUPattern;
/*!
@class ICUMatcher
@abstract ICUMatcher provides matching functionality for regular expression matching.
@discussion This class is based off of the <a href="http://icu.sourceforge.net/apiref/icu4c/classRegexMatcher.html">C++ ICU RegexMatcher class</a>. For examples of how to use the matcher, see the NSString category included in this project.
*/
@interface ICUMatcher : NSObject {
ICUPattern *pattern;
}
/*!
@method matcherWithPattern:overString:
@abstract Returns a matcher that can match the given pattern over the given string.
@discussion
*/
+(ICUMatcher *)matcherWithPattern:(ICUPattern *)p overString:(NSString *)stringToSearchOver;
/*!
@method initWithPattern:overString:
@abstract Initializes a matcher that can match the given patter over the given string.
@discussion
*/
-(ICUMatcher *)initWithPattern:(ICUPattern *)p overString:(NSString *)stringToSearchOver;
/*!
@method findNext
@abstract Finds the next occurrence of the pattern in the input string.
@discussion Use <code>group</code> and <code>rangeOfMatch</code> to extract the match.
*/
-(BOOL)findNext;
/*!
@method findFromIndex:
@abstract Resets the pattern and performs a match from the specified index.
@discussion Use <code>group</code> and <code>rangeOfMatch</code> to extract the match.
*/
-(BOOL)findFromIndex:(unsigned)idx;
/*!
@method group
@abstract Returns the current match.
@discussion Each match has one or more subexpressions associated with the match. This returns the entire match.
*/
-(NSString *)group;
/*!
@method groupAtIndex:
@abstract Returns the given subexpression for the current match.
@discussion <code>group</code> is equivalent to <code>groupAtIndex:0</code>. The subexpressions for a match are indexed from 1.
*/
-(NSString *)groupAtIndex:(unsigned)groupIndex;
/*!
@method numberOfGroups
@abstract Returns the number of groups for the current match.
@discussion Group 0 is the entire match and groups 1..n represent the groups for the subexpressions.
*/
-(unsigned)numberOfGroups;
/*!
@method lookingAt:
@abstract Returns true if the pattern matches some prefix of the input string starting at the specified index.
@discussion This method returns YES when some prefix of the substring matches the input string.
*/
-(BOOL)lookingAt:(unsigned)idx;
/*!
@method pattern
@abstract Returns the pattern for this matcher.
@discussion
*/
-(ICUPattern *)pattern;
-(void)setPattern:(ICUPattern *)p;
/*!
@method matches
@abstract Returns YES if the patterns matches the <b>entire</b> input string.
@discussion
*/
-(BOOL)matches;
/*!
@method replaceAllWithString:
@abstract Replaces all occurrences of the pattern with the replacement string and returns the resulting string.
@discussion The replacement string can contain references to capture groups taking the form or $1, $2, etc.
*/
-(NSString *)replaceAllWithString:(NSString *)aReplacementString;
/*!
@method replaceFirstWithString:
@abstract Replaces the first occurrence of the pattern with the given replacement string and returns the resulting string.
@discussion The replacement string can contain references to capture groups taking the form or $1, $2, etc.
*/
-(NSString *)replaceFirstWithString:(NSString *)aReplacementString;
/*!
@method reset
@abstract Resets any state associated with the matcher and its pattern.
@discussion
*/
-(void)reset;
/*!
@method rangeOfMatch
@abstract Returns the range of the input string that corresponds to the current match.
@discussion
*/
-(NSRange)rangeOfMatch;
/*!
@method rangeOfMatchGroup:
@abstract Returns the range of the input string that corresponds to the specified capture group of the current match.
@discussion
*/
-(NSRange)rangeOfMatchGroup:(unsigned)groupNumber;
@end