90
* Assignment operator overloading.
91
* Set the regular expression
92
* to be used on subject strings
93
* and compile the regular expression
96
* @param pattern The new pattern
98
Pattern& operator=(const std::string& pattern) {
104
Pattern& operator=(const char * pattern) {
111
* Compile the regular expression
112
* from the pattern that was set for
118
* Get the currently set regular expression
119
* that is used on subject strings
121
* @return The currently set pattern
123
std::string getPattern() const {
128
* << operator overload. Sets the the subject
129
* for latter use on the >> operator.
132
* The expression to be evaluated
136
void operator<< (const std::string& subject) {
141
* Get the start position of the overall match.
143
* @return the start position of the overall match.
145
size_t start() const;
148
* Get the start position of the specified match.
150
* @param groupNumber The capturing group number.
152
* @return the start position of the specified match.
154
size_t start(unsigned int groupNumber) const;
157
* Get the start position of the specified match.
159
* @param groupName The capturing group name.
161
void start(const std::string& groupName) const;
164
* Get the end position of the overall match.
166
* @return the end position of the overall match.
171
* Get the end position of the specified match.
173
* @param groupNumber The capturing group number.
175
* @return the end position of the specified match.
177
size_t end(unsigned int groupNumber) const;
180
* Get the end position of the specified match.
182
* @param groupName The capturing group name.
184
* @return the end position of the specified match.
186
void end(const std::string& groupName) const;
189
* Get the number of capturing groups in the
192
* @return The number of capture groups.
194
* @pre The regular expression should have been
195
* compiled prior to the execution of this method.
197
unsigned int getCaptureGroupCount();
200
90
* Get the substring matched in a capturing
201
91
* group (named or unnamed).
212
102
* regular expression designated
213
103
* the group name.
215
std::string group(const std::string& groupName);
218
* Get the substring matched in a named group.
220
* This methods only performs a basic lookup
221
* inside its internal substring table. Thus,
222
* matches() should have been called prior to
223
* this method in order to obtain the desired
226
* @param groupNumber The number of the group.
228
* @return the substring matched by the
229
* regular expression designated
232
std::string group(int groupNumber);
235
* Similar to python's MatchObject.groups. Get all
236
* the substrings matched by the capture groups defined
237
* in the pattern. The complete (implicit) capture group
238
* is not returned : ie only groups from 1 up to the number
239
* of groups in the pattern are returned.
241
* @return A vector of stings that were matched by some
242
* capturing group in the pattern.
244
* @pre The regular expression should have been
245
* compiled prior to the execution of this method.
247
std::vector<std::string> groups();
250
* Try to match the compiled pattern with a
253
* @param subject Subject to be matched
256
* @return true If the subject matches the pattern,
259
* @pre The regular expression should have been
260
* compiled prior to the execution of this method.
262
* @post The internal substring table will be updated
263
* with the new matches. Therefore, subsequent
264
* calls to group may return different results.
266
bool matches(const std::string& subject);
105
std::string group(const char *groupName);
269
108
* Try to match the compiled pattern with the implicit
296
135
std::vector<std::string> split();
137
void updateSubject(const std::string& subject) {
143
* Get the start position of the overall match.
145
* @return the start position of the overall match.
147
size_t start() const;
150
* Get the end position of the overall match.
152
* @return the end position of the overall match.
299
156
NON_COPYABLE(Pattern);
300
157
// The regular expression that represents that pattern.
301
158
std::string pattern_;