match_results:
#include <regex>
template <
typename BidirectionalIterator,
typename Allocator = allocator<sub_match<BidirectionalIterator> >
> class match_results;
The class template match_results
holds a collection of character sequences that represent the result of a regular expression match. Several specializations for common character sequence types are provided:
typedef match_results<const char*> cmatch;
typedef match_results<const wchar_t*> wcmatch;
typedef match_results<std::string::const_iterator> smatch;
typedef match_results<std::wstring::const_iterator> wsmatch;
字匹配的类型
wssub_match
csub_match wcsub_match ssub_match
Member types
Member type | Definition |
---|---|
sub_match<BidirectionalIterator> | value_type |
const value_type& | const_reference |
const_reference | reference |
(implementation-defined) | const_iterator |
const_iterator | iterator |
typename iterator_traits<BidirectionalIterator>::difference_type | difference_type |
typename allocator_traits<Allocator>::size_type | size_type |
Allocator | allocator_type |
typename iterator_traits<BidirectionalIterator>::value_type | char_type |
std::basic_string<char_type> | string_type |
Member functions
Constructors | create a match |
Operators | assign values to a match |
get_allocator | returns the allocator for this object |
swap | swaps the matched sub-expressions with another match_results |
Size
Element access
length | the length of a particular sub-expression |
position | the distance between the start of the target sequence and a given sub-expression |
str | the sequence of characters for a given sub-expression |
operator_at | returns a reference to the sub_match for a specific sub-expression |
prefix | the characters from the start of the original sequence to the beginning of the match |
suffix | the characters from the end of the match to the end of the original sequence |
begin,cbegin | an iterator that enumerates the sub-expressions in *this |
end,cend | an iterator that terminates the sub-expressions in *this |
Formatting
length | length(int sub=0) 指定子表达式的长度 |
position | position(int sub=0) 指定子表达式与被匹配串开头之间的字节数 |
str | str(int sub=0) 指定子表达式匹配得到的字串的长度 |
operator_at | []返回子匹配 |
prefix | 原始串的开头到第一个匹配点的字节数 |
suffix | 匹配点的下一个位置到原始串结束的字节数 |
begin,cbegin | 返回指向第一个子匹配(what[0])的迭代器
|
end,cend |
format | formats match results for output |