std::match_results<BidirIt,Alloc>::prefix
來自 cppreference.com
< cpp | regex | match results
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
[編輯] 另請參閱
返回完整匹配結束與目標序列結束之間的子序列 (公共成員函式) |