Module: Essential Tools Module Group: String Processing Classes
Does not inherit
#include <rw/tools/regex.h> #include <rw/cstring.h> RWTRegex<char> pattern("a+"); RWTRegexResult<char> result = pattern.search("aabbccaadd");
Class RWTRegexResult<T> is a class template that encapsulates the result of a matchAt or search operation executed on an instance of RWTRegex<T>.
None
#include <rw/tools/regex.h> #include <rw/cstring.h> #include <iostream> int main() { RWTRegex<char> pattern("h(t+)p"); RWCString str("http"); RWTRegexResult<char> result = pattern.search(str); std::cout << "Overall match at offset " << result.getStart() << ", with length " << result.getLength() << " is " << result.subString(str) << std::endl; std::cout << "First sub-expression match at offset " << result.getStart(1) << ", with length " << result.getLength(1) << " is " << result.subString(str, 1) << std::endl; return 0; }
Program Output:
Overall match at offset 0, with length 4 is http First sub-expression match at offset 1, with length 2 is tt
RWTRegexResult();
Default constructor
RWTRegexResult(const RWTRegexResult<E>& source);
Copy constructor
~RWTRegexResult();
Destructor
RWTRegexResult<E>& operator=(const RWTRegexResult& rhs);
Assignment operator
bool operator() const
Match operator
size_t size() const;
Returns the number of match IDs available for request, including the 0 match ID. Hence, the largest matchID that can be requested is size() -1.
size_t getStart(size_t matchID = 0) const;
Returns the offset of the start of the requested match.
size_t getLength(size_t matchID = 0) const;
Returns the length of the requested match.
RString subString(const RString& str, size_t matchID = 0) const;
Returns a substring containing the requested match. Only available in C++ Standard Library builds.
© 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.