Movatterモバイル変換


[0]ホーム

URL:


cppreference.com
Namespaces
Variants
    Actions

      std::regex_iterator<BidirIt,CharT,Traits>::regex_iterator

      From cppreference.com
      <cpp‎ |regex‎ |regex iterator
       
       
       
      Regular expressions library
      Classes
      (C++11)
      Algorithms
      Iterators
      Exceptions
      Traits
      Constants
      (C++11)
      Regex Grammar
       
       
      regex_iterator();
      (1)(since C++11)
      regex_iterator( BidirIt a, BidirIt b,

                     const regex_type& re,
                     std::regex_constants::match_flag_type m=

                         std::regex_constants::match_default);
      (2)(since C++11)
      regex_iterator(const regex_iterator&);
      (3)(since C++11)
      regex_iterator( BidirIt, BidirIt,

                     const regex_type&&,
                     std::regex_constants::match_flag_type=

                         std::regex_constants::match_default)= delete;
      (4)(since C++11)

      Constructs a newregex_iterator:

      1) Default constructor. Constructs an end-of-sequence iterator.
      2) Constructs aregex_iterator from the sequence of characters[ab), the regular expressionre, and a flagm that governs matching behavior. This constructor performs an initial call tostd::regex_search with this data. If the result of this initial call isfalse,*this is set to an end-of-sequence iterator.
      3) Copies aregex_iterator.
      4) The overload(2) is not allowed to be called with a temporary regex, since the returned iterator would be immediately invalidated.

      [edit]Parameters

      a -LegacyBidirectionalIterator to the beginning of the target character sequence
      b -LegacyBidirectionalIterator to the end of the target character sequence
      re - regular expression used to search the target character sequence
      m - flags that govern the behavior ofre

      [edit]Example

      Run this code
      #include <iostream>#include <regex>#include <string_view> int main(){constexprstd::string_view str{R"(        #ONE: *p = &Mass;        #Two: MOV %rd, 42    )"};conststd::regex re("[a-w]"); // create regex_iterator, overload (2)auto it=std::regex_iterator<std::string_view::iterator>{        str.cbegin(), str.cend(),        re// re is lvalue; if an immediate expression was used// instead, e.g. std::regex{"[a-z]"}, this would// produce an error since overload (4) is deleted}; for(decltype(it) last/* overload (1) */; it!= last;++it)std::cout<<(*it).str();std::cout<<'\n';}

      Output:

      password

      [edit]Defect reports

      The following behavior-changing defect reports were applied retroactively to previously published C++ standards.

      DRApplied toBehavior as publishedCorrect behavior
      LWG 2332C++11aregex_iterator constructed from a temporary
      basic_regex became invalid immediately
      such construction is disallowed via a deleted overload
      Retrieved from "https://en.cppreference.com/mwiki/index.php?title=cpp/regex/regex_iterator/regex_iterator&oldid=161422"

      [8]ページ先頭

      ©2009-2025 Movatter.jp