| Home | Libraries | People | FAQ | More

## Struct mark_tag

boost::xpressive::mark_tag — Sub-match placeholder type, used to create named captures in static regexes.

## Synopsis

    // In header: <boost/xpressive/regex_primitives.hpp>

    struct mark_tag {
      // construct/copy/destruct
      mark_tag(int);

      // private static functions
      static unspecified make_tag(int) ;
    };

## Description

`mark_tag` is the type of the global sub-match placeholders `s0`, `s1`, etc.. You can use the `mark_tag` type to create your own sub-match placeholders with more meaningful names. This is roughly equivalent to the "named capture" feature of dynamic regular expressions.

To create a named sub-match placeholder, initialize it with a unique integer. The integer must only be unique within the regex in which the placeholder is used. Then you can use it within static regexes to created sub-matches by assigning a sub-expression to it, or to refer back to already created sub-matches.

     mark_tag number(1); // "number" is now equivalent to "s1"
     // Match a number, followed by a space and the same number again
     sregex rx = (number = +_d) >> ' ' >> number;

After a successful `regex_match()` or `regex_search()`, the sub-match placeholder can be used to index into the `match_results<>` object to retrieve the corresponding sub-match.

### `mark_tag` public construct/copy/destruct

1.     mark_tag(int mark_nbr);

   Initialize a mark_tag placeholder.

   Parameters: |
   `mark_nbr` | An integer that uniquely identifies this `mark_tag` within the static regexes in which this `mark_tag` will be used.
   Requires: | `mark_nbr > 0`

### `mark_tag` private static functions

1.     static unspecified make_tag(int mark_nbr) ;