std::sub_match::operator string_type, std::sub_match::str

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​

版本历史

  • (当前 | 先前 2017年10月13日 (五) 10:01Fruderica讨论 | 贡献. . (827字节) (-632). . (撤销)
  • 当前 | 先前 2014年10月26日 (日) 18:07P12bot讨论 | 贡献 . . (1,459字节) (0). . (Fix some translations) (撤销)
  • 当前 | 先前 2013年7月2日 (二) 11:16P12bot讨论 | 贡献 . . (1,459字节) (-28). . (Use {{lc}}. Update links. Various fixes.) (撤销)
  • 当前 | 先前 2012年11月2日 (五) 11:20P12bot讨论 | 贡献 . . (1,487字节) (+249). . (r2.7.3) (机器人添加:de, en, es, fr, it, ja, pt, ru) (撤销)
  • 当前 | 先前 2012年10月27日 (六) 12:11P12讨论 | 贡献 . . (1,238字节) (0). . (1个修订: Translate from the English version) (撤销)
  • 当前 | 先前 2012年10月26日 (五) 06:00TranslationBot讨论 | 贡献. . (1,238字节) (-44). . (Translated from the English version using Google Translate) (撤销)
  • 当前 | 先前 2012年10月25日 (四) 15:33P12讨论 | 贡献 . . (1,282字节) (0). . (1个修订: Translate from the English version) (撤销)
  • 当前 | 先前) 2012年10月25日 (四) 12:00TranslationBot讨论 | 贡献. . (1,282字节) (+1,282). . (Translated from the English version using Google Translate)