Document Number P0014R1
Date 2015-10-30
Audience Library Working Group
Reply-To
  • Nozomu Katō
  • <
  • tantataotaztata
  • .ta.
  • taktataata
  • taatataktaetatantaotatattastatautaktataita
  • .ta.
  • tactataotamtata
  • >

Proposal to add the multiline option to std::regex for its ECMAScript engine

Introduction and Motivation

std::regex in the C++ standard has an engine that recognizes the ECMAScript grammar. But unlike the original RegExp of ECMAScript, this engine does not have a way to switch the behaviors of the regular expressions ^ and $, because there is not any option corresponding to the multiline property in ECMAScript. To fix this incompatibility and to make the behavior of this engine more compatible with the original RegExp of ECMAScript, I propose adding an option to std::regex for switching the behaviors of the regular expressions ^ and $.

Proposed Additions

  1. To syntax_option_type in 28.5.1 [re.synopt]:

    constexpr syntax_option_type multiline = unspecified ;

  2. To the end of the text in 28.5.1 [re.synopt]:

    When one of grammars other than ECMAScript is specified, if the flag multiline is set, the value is not valid. [Note: With multiline, ^ matches the beginning of every line in addition to the beginning of the input sequence, and $ matches the end of every line in addition to the end of the input sequence. ―― end note]

  3. To Table 138 in 28.5.1 [re.synopt]:

    Element: multiline
    Effect(s) if set: Specifies that ^ and $ shall behave according to the specification in ECMA-262 with the condition that Multiline is true, if the ECMAScript grammar is specified.

  4. Into class basic_regex in 28.8 [re.regex]:

    static constexpr regex_constants::syntax_option_type
      multiline = regex_constants::multiline;

  5. To basic_regex constants in 28.8.1 [re.regex.const]:

    static constexpr regex_constants::syntax_option_type
      multiline = regex_constants::multiline;

Relevant Information

I reported this as a library issue once and it was listed as Issue #2503, but based on a recommendation I submit this matter as a proposal.

Revision History