std::match_results<BidirIt,Alloc>:: position
| Localization library | |||||||||||||||||||||||||
| Regular expressions library (C++11) | |||||||||||||||||||||||||
| Formatting library (C++20) | |||||||||||||||||||||||||
| Null-terminated sequence utilities | |||||||||||||||||||||||||
| Byte strings | |||||||||||||||||||||||||
| Multibyte strings | |||||||||||||||||||||||||
| Wide strings | |||||||||||||||||||||||||
| Primitive numeric conversions | |||||||||||||||||||||||||
|
|||||||||||||||||||||||||
| Text encoding identifications | |||||||||||||||||||||||||
|
|||||||||||||||||||||||||
| Classes | ||||
|
(C++11)
|
||||
|
(C++11)
|
||||
|
(C++11)
|
||||
| Algorithms | ||||
|
(C++11)
|
||||
|
(C++11)
|
||||
|
(C++11)
|
||||
| Iterators | ||||
|
(C++11)
|
||||
|
(C++11)
|
||||
| Exceptions | ||||
|
(C++11)
|
||||
| Traits | ||||
|
(C++11)
|
||||
| Constants | ||||
|
(C++11)
|
||||
|
(C++11)
|
||||
|
(C++11)
|
||||
| Regex Grammar | ||||
|
(C++11)
|
| Member functions | ||||
| State | ||||
| Element access | ||||
|
match_results::position
|
||||
| Iterators | ||||
| Format | ||||
| Modifiers | ||||
| Non-member functions | ||||
|
(until C++20)
|
||||
|
difference_type position
(
size_type n
=
0
)
const
;
|
(自 C++11 起) | |
返回指定子匹配项首字符的位置。
如果 n == 0 ,则返回整个匹配表达式第一个字符的位置。
如果 n > 0 && n < size ( ) ,则返回第 n 个子匹配项首字符的位置。
如果 n >= size ( ) ,则返回未匹配部分的第一个字符位置。
ready()
必须为
true
。否则行为是未定义的。
目录 |
参数
| n | - | 用于指定要检查的匹配项的整数值 |
返回值
指定匹配或子匹配的首字符位置。
示例
#include <iostream> #include <regex> #include <string> int main() { std::regex re("a(a)*b"); std::string target("aaab"); std::smatch sm; std::regex_match(target, sm, re); std::cout << sm.position(1) << '\n'; }
输出:
2
参见
|
返回指定的子匹配
(公开成员函数) |