Module: Essential Tools Module Group: String Processing Classes
Does not inherit
#include <rw/tools/regex.h> #include <rw/cstring.h> RWTRegex<char> pattern("a+"); RWCString str("aabbccaadd"); RWTRegexMatchIterator<char> i(pattern, str);
Class RWTRegexMatchIterator<T> is an iterator class provided with RWTRegex for iteration over matches of a pattern in a given string.
None
#include <rw/tools/regex.h> #include <rw/cstring.h> #include <iostream> int main() { RWCString pattern("a+"); RWCString str("aaabaacadeaaaafgaaa"); // Compile the pattern RWTRegex<char> r(pattern); // Iterate over all occurrences of the "pattern" string in // "str" for (RWTRegex<char>::iterator i(r, str); i != RWTRegex<char>::iterator(); ++i) { std::cout << "Found match at index, " << i-> getStart() << ":" << i-> subString(str) << std::endl; } return 0; } Program Output:
Found match at index, 0 :aaa Found match at index, 4 :aa Found match at index, 7 :a Found match at index, 10 :aaaa Found match at index, 16 :aaa
RWTRegexMatchIterator();
Default constructor
RWTRegexMatchIterator(const RWTRegexMatchIterator<T>& source);
Copy constructor
RWTRegexMatchIterator(RWTRegex<T>& regex, const RChar* str, size_t start = size_t(0), size_t length = size_t(-1));
Constructor. Initializes a match iterator to the first match in string, starting from the start character offset, of the regular expression pattern given in regex. The parameter length defines the length of string. If not specified, the length is calculated as the number of characters up to the first null character, according to the character traits.
RWTRegexMatchIterator(RWTRegex<T>& regex, const RString& str, size_t start = size_t(0), size_t length = size_t(-1));
Constructor. Initializes a match iterator to the first match in string, starting from the start character offset, of the regular expression pattern given in regex. The parameter length identifies the length of the of the string. If not specified, the length is assigned the length of the "string" object.
~RWTRegexMatchIterator();
Destructor
RWTRegexMatchIterator& operator=(const RWTRegexMatchIterator& rhs);
Assignment operator
RWTRegexMatchIterator& operator++();
Pre-increment operator
const RWTRegexMatchIterator operator++(int);
Post-increment operator
RWTRegexMatchIterator& operator+=(size_t count);
Advances through count matches.
RWTRegexResult<T>& operator*() const;
Dereferences the iterator, giving a reference to the regular expression object represented in the iterator.
RWTRegexResult<T>* operator->() const;
Returns a pointer to the regular expression object represented in the iterator.
bool operator==(const RWTRegexMatchIterator& rhs) const;
Compares two iterators for equality through comparison of the regular expression and the starting position in the string.
bool operator!=(const RWTRegexMatchIterator& rhs) const;
Determines if two iterators are unequal. The return value of this method is the same as !(*this == rhs).
© Copyright Rogue Wave Software, Inc. All Rights Reserved.
Rogue Wave and SourcePro are registered trademarks of Rogue Wave Software, Inc. in the United States and other countries. All other trademarks are the property of their respective owners.
Contact Rogue Wave about documentation or support issues.