std::match_results<BidirIt,Alloc>::prefix
来自cppreference.com
< cpp | regex | match results
正则表达式库
| 类 | ||||
|
(C++11)
|
||||
|
(C++11)
|
||||
|
(C++11)
|
||||
| 算法 | ||||
|
(C++11)
|
||||
|
(C++11)
|
||||
|
(C++11)
|
||||
| 迭代器 | ||||
|
(C++11)
|
||||
|
(C++11)
|
||||
| 异常 | ||||
|
(C++11)
|
||||
| 特性 | ||||
|
(C++11)
|
||||
| 常量 | ||||
|
(C++11)
|
||||
|
(C++11)
|
||||
|
(C++11)
|
||||
| 正则表达式文法 | ||||
|
(C++11)
|
std::match_results
| 成员函数 | ||||
| 状态 | ||||
| 成员访问 | ||||
|
match_results::prefix
|
||||
| 迭代器 | ||||
| 格式 | ||||
| 修改器 | ||||
| 非成员函数 | ||||
|
(C++20
前)
|
||||
|
const_reference
prefix()
const;
|
(C++11 起) | |
获得到 std::sub_match 对象的引用,该对象表示目标序列起始到正则表达式的整个匹配起始之间的目标序列。
除非 ready() == true ,否则行为未定义。
参数
(无)
返回值
到未匹配前缀的引用。
示例
运行此代码
#include <iostream> #include <regex> #include <string> int main() { std::regex re("a(a)*b"); std::string target("baaaby"); std::smatch sm; std::regex_search(target, sm, re); std::cout << sm.prefix().str() << '\n'; }
输出:
b