public member function
<regex>

std::match_results::operator=

copy (1)
match_results& operator= (const match_results& m);
move (2)
match_results& operator= (match_results&& m);
Assign value to match_results
Copies (or moves) the contents and all the properties of m into the match_results object.

Parameters

m
Another match_results object.

Return value

*this

Example

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
// match_results::operator=
// - using cmatch, a standard alias of match_results<const char*>
#include <iostream>
#include <regex>

int main ()
{
  std::cmatch m1,m2;

  std::regex_match ( "subject", m1, std::regex("(sub)(.*)") );

  m2 = m1;    // copy assignment

  for (unsigned i=0; i<m2.size(); ++i)
    std::cout << "match " << i << ": " << m2[i] << std::endl;

  return 0;
}


Output:
match 0: subject
match 1: sub
match 2: ject

See also