<!doctype html>
<html lang="en">
<head>
	<meta charset="utf-8">
	<title>Proposal to add the multiline option to std::regex for its ECMAScript engine</title>
	<style type="text/css">
	*
	{
		font-family: calibri;
	}
	body
	{
		color: #000000;
		background-color: #fcfcfc;
	}
	code
	{
		font-family: monospace;
		font-size: 0.9em;
		color: #3f3f3f;
		font-weight: bold;
	}
	h1, h2
	{
		color: #365f91;
	}
	h1
	{
		margin-bottom: 1.2em;
	}
	p
	{
		text-indent: 1.2em;
		line-height: 1.44em;
	}
	li p
	{
		text-indent: 0;
	}
	li p.addition
	{
		padding: 0.25em 1em;
		background-color: #efefef;
	}
	section
	{
		margin-bottom: 1.8em;
	}
	span.note
	{
		font-style: italic;
	}
	table#meta th
	{
		text-align: left;
	}
	ul#ma
	{
		display: inline;
		margin-left: 0;
		padding-left: 0;
	}
	ul#ma li
	{
		display: inline;
		list-style-type: none;
	}
	ul#ma li .tanuki
	{
		display: none;
	}
	ul#ma li span.postp:after
	{
		content: ' . ';
	}
	ul#ma li span#am:before
	{
		content: ' at ';
	}
	ul#ma li span.prep:before
	{
		content: ' . ';
	}
	</style>
</head>
<body>

<table id="meta">
	<tr>
		<th>Document Number</th>
		<td>P0014R1</td>
	</tr>
	<tr>
		<th>Date</th>
		<td>2015-10-30</td>
	</tr>
	<tr>
		<th>Audience</th>
		<td>Library Working Group</td>
	</tr>
	<tr>
		<th>Reply-To</th>
		<td>
			<ul id="ma">
				<li>Nozomu Katō</li>
				<li>&lt;</li><li><span class="tanuki">ta</span>n<span class="tanuki">tata</span>o<span class="tanuki">ta</span><span class="postp">z</span><span class="tanuki">tata</span></li>
				<li><span class="tanuki">.ta.</span></li>
				<li><span class="tanuki">ta</span>k<span class="tanuki">tata</span>a<span class="tanuki">ta</span></li>
				<li><span id="am"> </span></li>
				<li><span class="tanuki">ta</span>a<span class="tanuki">tata</span>k<span class="tanuki">ta</span>e<span class="tanuki">tata</span>n<span class="tanuki">ta</span>o<span class="tanuki">tata</span>t<span class="tanuki">ta</span>s<span class="tanuki">tata</span>u<span class="tanuki">ta</span>k<span class="tanuki">tata</span>i<span class="tanuki">ta</span></li>
				<li><span class="tanuki">.ta.</span></li>
				<li><span class="tanuki">ta</span><span class="prep">c</span><span class="tanuki">tata</span>o<span class="tanuki">ta</span>m<span class="tanuki">tata</span></li><li>&gt;</li>
			</ul>
		</td>
	</tr>
</table>

<h1>Proposal to add the multiline option to std::regex for its ECMAScript engine</h1>

<section>
	<h2>Introduction and Motivation</h2>
	<p>
	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 $.
	</p>
</section>

<section>
	<h2>Proposed Additions</h2>
	<ol>
		<li>
			<p>
			To syntax_option_type in 28.5.1 [re.synopt]:
			</p>
			<p class="addition">
			constexpr syntax_option_type multiline = unspecified ;
			</p>
		</li>
		<li>
			<p>
			To the end of the text in 28.5.1 [re.synopt]:
			</p>
			<p class="addition">
			When one of grammars other than ECMAScript is specified, if the flag multiline is set, the value is not valid. [<span class="note">Note</span>: 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. ―― <span class="note">end note</span>]
			</p>
		</li>
		<li>
			<p>
			To Table 138 in 28.5.1 [re.synopt]:
			</p>
			<p class="addition">
			Element: multiline<br>
			Effect(s) if set: Specifies that ^ and $ shall behave according to the specification in ECMA-262 with the condition that <code>Multiline</code> is <code>true</code>, if the ECMAScript grammar is specified.
			</p>
		</li>
		<li>
			<p>
			Into class basic_regex in 28.8 [re.regex]:
			</p>
			<p class="addition">
			static constexpr regex_constants::syntax_option_type<br>
			&nbsp;&nbsp;multiline = regex_constants::multiline;
			</p>
		</li>
		<li>
			<p>
			To basic_regex constants in 28.8.1 [re.regex.const]:
			</p>
			<p class="addition">
			static constexpr regex_constants::syntax_option_type<br>
			&nbsp;&nbsp;multiline = regex_constants::multiline;
			</p>
		</li>
	</ol>
</section>

<section>
	<h2>Relevant Information</h2>
	<p>
	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.
	</p>
</section>

<section>
	<h2>Revision History</h2>
	<ul>
		<li>Changes since D1: Updated the Proposed Additions section based on the committee's comments.</li>
		<li>Changes since R0: Added clauses 3 and 4 to the Proposed Addtions section.</li>
	</ul>
</section>

</body>
</html>
