std::match_results<BidirIt,Alloc>::prefix
来自cppreference.com
| |
(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
参阅
| 返回完整匹配结尾和目标序列结尾之间的子序列 (公开成员函数) |