boost::regex

 

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
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 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

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值