Namespaces
Variants

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

From cppreference.net
Regular expressions library
Classes
(C++11)
Algorithms
Iterators
Exceptions
Traits
Constants
(C++11)
Regex Grammar
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

関連項目

完全一致の終端と対象シーケンスの終端の間の部分シーケンスを返す
(公開メンバ関数)