boost::regex

来源:互联网 发布:制作cf刷枪软件 编辑:程序博客网 时间:2024/05/12 17:19

 

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;
字匹配的类型
csub_matchwcsub_matchssub_match
wssub_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 matchOperators assign values to a matchget_allocator returns the allocator for this objectswap swaps the matched sub-expressions with another match_results
Size
size 如果匹配成功,返回 1 + 匹配的子表达式个数max_size 最多可存储子匹配的个数empty 返回true 当有至少一个子匹配时,否则返回false
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 matchsuffix the characters from the end of the match to the end of the original sequencebegin,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