std::match_results::prefix

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

版本历史

  • (当前 | 先前 2017年9月29日 (五) 01:20Fruderica讨论 | 贡献. . (733字节) (-347). . (撤销)
  • 当前 | 先前 2014年10月26日 (日) 18:06P12bot讨论 | 贡献 . . (1,080字节) (0). . (Fix some translations) (撤销)
  • 当前 | 先前 2012年11月2日 (五) 12:10P12bot讨论 | 贡献 . . (1,080字节) (+305). . (r2.7.3) (机器人添加:de, en, es, fr, it, ja, pt, ru) (撤销)
  • 当前 | 先前 2012年10月27日 (六) 09:07P12讨论 | 贡献 . . (775字节) (0). . (1个修订: Translate from the English version) (撤销)
  • 当前 | 先前 2012年10月26日 (五) 06:00TranslationBot讨论 | 贡献. . (775字节) (-30). . (Translated from the English version using Google Translate) (撤销)
  • 当前 | 先前 2012年10月25日 (四) 15:33P12讨论 | 贡献 . . (805字节) (0). . (1个修订: Translate from the English version) (撤销)
  • 当前 | 先前) 2012年10月25日 (四) 12:00TranslationBot讨论 | 贡献. . (805字节) (+805). . (Translated from the English version using Google Translate)