std::sub_match<BidirIt>::operator string_type, std::sub_match<BidirIt>::str
来自cppreference.com
正则表达式库
类 | ||||
(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::sub_match
成员函数 | ||||
sub_match::strsub_match::operator
string_type
|
||||
非成员函数 | ||||
(C++20
前)(C++20
前)(C++20
前)(C++20
前)(C++20
前)(C++20)
|
||||
operator
string_type()
const;
|
(1) | |
string_type
str()
const;
|
(2) | |
转换为底层 std::basic_string 类型对象。
第一版本为隐式转换,第二版本为显式。
参数
(无)
返回值
返回作为底层 std::basic_string
类型对象的匹配字符序列。若 matched
成员为 false 则返回空字符串。
复杂度
与底层字符序列的长度成线性。
示例
运行此代码
#include <iostream> #include <regex> #include <string> int main() { std::ssub_match sm; std::string s = sm; // 隐式转换 std::cout << s.length() << '\n'; }
输出:
0