Skip to content

Latest commit

 

History

History
81 lines (66 loc) · 1.82 KB

File metadata and controls

81 lines (66 loc) · 1.82 KB

flags

  • regex[meta header]
  • std[meta namespace]
  • basic_regex[meta class]
  • function[meta id-type]
  • cpp11[meta cpp]
flag_type flags() const;

概要

最後に設定された正規表現フラグを返す。

戻り値

最後に設定された正規表現フラグ

備考

flag_typeregex_constants::syntax_option_type の別名である。

#include <iostream>
#include <regex>

# define PRINTFLAG(f, FLAG) (std::cout << #FLAG " is " << (f & std::regex_constants::FLAG ? "set" : "n

void print(std::regex_constants::syntax_option_type f)
{
  PRINTFLAG(f, icase);
  PRINTFLAG(f, nosubs);
  PRINTFLAG(f, optimize);
  PRINTFLAG(f, collate);
  PRINTFLAG(f, ECMAScript);
  PRINTFLAG(f, basic);
  PRINTFLAG(f, extended);
  PRINTFLAG(f, awk);
  PRINTFLAG(f, grep);
  PRINTFLAG(f, egrep);
}

int main()
{
  std::regex re("(\\w+) (\\d+) (\\w+)", std::regex_constants::icase | std::regex_constants::optimize);
  print(re.flags());
}
  • flags[color ff0000]
  • std::regex_constants::syntax_option_type[link ../regex_constants/syntax_option_type.md]
  • std::regex_constants::icase[link ../regex_constants/syntax_option_type.md]
  • std::regex_constants::optimize[link ../regex_constants/syntax_option_type.md]

出力

icase is set
nosubs is not set
optimize is set
collate is not set
ECMAScript is not set
basic is not set
extended is not set
awk is not set
grep is not set
egrep is not set

バージョン

言語

  • C++11

処理系