名稱空間
變體
操作

std::match_results<BidirIt,Alloc>::prefix

來自 cppreference.com
< cpp‎ | regex‎ | match results
 
 
 
正則表示式庫
(C++11)
演算法
迭代器
異常
特性
常量
(C++11)
正則表示式語法
 
 
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

[編輯] 另請參閱

返回完整匹配結束與目標序列結束之間的子序列
(公共成員函式) [編輯]