mirror of
https://github.com/bendtherules/ask262.git
synced 2026-08-18 13:21:55 +00:00
3865 lines
633 KiB
HTML
3865 lines
633 KiB
HTML
<!DOCTYPE html><html lang="en-GB-oxendict"><head><meta name="viewport" content="width=device-width, initial-scale=1"><meta charset="utf-8"><meta property="og:image" content="https://tc39.es/ecmarkup/ecma-logo.png"><meta property="og:title" content="ECMAScript® 2026 Language Specification"><meta property="og:description" content="Introduction
|
||
This Ecma Standard defines the ECMAScript 2026 Language. It is the seventeenth edition of the ECMAScript Language Specification. ECMAScript is based on several originating technologies, the most well-known being JavaScript (Netscape) and JScript (Microsoft). The language was invent">
|
||
<link rel="icon" href="../img/favicon.ico">
|
||
<link rel="stylesheet" href="../assets/css/ecmarkup.css"><link rel="stylesheet" href="../assets/css/print.css" media="print">
|
||
|
||
<title>ECMAScript® 2026 Language Specification</title><script src="../assets/js/multipage.js?cache=Wu2V1pj2" defer=""></script><script src="../assets/js/ecmarkup.js?cache=BPFBckdu" defer=""></script><link rel="canonical" href="../#sec-text-processing"></head>
|
||
<body><div id="spec-container"><emu-clause id="sec-text-processing">
|
||
<h1><span class="secnum">22</span> Text Processing</h1>
|
||
|
||
<emu-clause id="sec-string-objects">
|
||
<h1><span class="secnum">22.1</span> String Objects</h1>
|
||
|
||
<emu-clause id="sec-string-constructor">
|
||
<h1><span class="secnum">22.1.1</span> The String Constructor</h1>
|
||
<p>The String <emu-xref href="#constructor" id="_ref_11273"><a href="ecmascript-data-types-and-values.html#constructor">constructor</a></emu-xref>:</p>
|
||
<ul>
|
||
<li>is <dfn tabindex="-1">%String%</dfn>.</li>
|
||
<li>is the initial value of the <emu-val>"String"</emu-val> property of the <emu-xref href="#sec-global-object" id="_ref_11274"><a href="global-object.html#sec-global-object">global object</a></emu-xref>.</li>
|
||
<li>creates and initializes a new String object when called as a <emu-xref href="#constructor" id="_ref_11275"><a href="ecmascript-data-types-and-values.html#constructor">constructor</a></emu-xref>.</li>
|
||
<li>performs a type conversion when called as a function rather than as a <emu-xref href="#constructor" id="_ref_11276"><a href="ecmascript-data-types-and-values.html#constructor">constructor</a></emu-xref>.</li>
|
||
<li>may be used as the value of an <code>extends</code> clause of a class definition. Subclass <emu-xref href="#constructor" id="_ref_11277"><a href="ecmascript-data-types-and-values.html#constructor">constructors</a></emu-xref> that intend to inherit the specified String behaviour must include a <code>super</code> call to the String <emu-xref href="#constructor" id="_ref_11278"><a href="ecmascript-data-types-and-values.html#constructor">constructor</a></emu-xref> to create and initialize the subclass instance with a <var class="field">[[StringData]]</var> internal slot.</li>
|
||
</ul>
|
||
|
||
<emu-clause id="sec-string-constructor-string-value" type="built-in function">
|
||
<h1><span class="secnum">22.1.1.1</span> String ( <var>value</var> )</h1>
|
||
<p>This function performs the following steps when called:</p>
|
||
<emu-alg><ol><li>If <var>value</var> is not present, then<ol><li>Let <var>s</var> be the empty String.</li></ol></li><li>Else,<ol><li>If NewTarget is <emu-val>undefined</emu-val> and <var>value</var> <emu-xref href="#sec-ecmascript-language-types-symbol-type" id="_ref_11279"><a href="ecmascript-data-types-and-values.html#sec-ecmascript-language-types-symbol-type">is a Symbol</a></emu-xref>, return <emu-xref aoid="SymbolDescriptiveString" id="_ref_11280"><a href="fundamental-objects.html#sec-symboldescriptivestring">SymbolDescriptiveString</a></emu-xref>(<var>value</var>).</li><li>Let <var>s</var> be ? <emu-xref aoid="ToString" id="_ref_11281"><a href="abstract-operations.html#sec-tostring" class="e-user-code">ToString</a></emu-xref>(<var>value</var>).</li></ol></li><li>If NewTarget is <emu-val>undefined</emu-val>, return <var>s</var>.</li><li>Return <emu-xref aoid="StringCreate" id="_ref_11282"><a href="ordinary-and-exotic-objects-behaviours.html#sec-stringcreate">StringCreate</a></emu-xref>(<var>s</var>, ? <emu-xref aoid="GetPrototypeFromConstructor" id="_ref_11283"><a href="ordinary-and-exotic-objects-behaviours.html#sec-getprototypefromconstructor" class="e-user-code">GetPrototypeFromConstructor</a></emu-xref>(NewTarget, <emu-val>"%String.prototype%"</emu-val>)).</li></ol></emu-alg>
|
||
</emu-clause>
|
||
</emu-clause>
|
||
|
||
<emu-clause id="sec-properties-of-the-string-constructor">
|
||
<h1><span class="secnum">22.1.2</span> Properties of the String Constructor</h1>
|
||
<p>The String <emu-xref href="#constructor" id="_ref_11284"><a href="ecmascript-data-types-and-values.html#constructor">constructor</a></emu-xref>:</p>
|
||
<ul>
|
||
<li>has a <var class="field">[[Prototype]]</var> internal slot whose value is <emu-xref href="#sec-properties-of-the-function-prototype-object" id="_ref_11285"><a href="fundamental-objects.html#sec-properties-of-the-function-prototype-object">%Function.prototype%</a></emu-xref>.</li>
|
||
<li>has the following properties:</li>
|
||
</ul>
|
||
|
||
<emu-clause id="sec-string.fromcharcode" type="built-in function">
|
||
<h1><span class="secnum">22.1.2.1</span> String.fromCharCode ( ...<var>codeUnits</var> )</h1>
|
||
<p>This function may be called with any number of arguments which form the rest parameter <var>codeUnits</var>.</p>
|
||
<p>It performs the following steps when called:</p>
|
||
<emu-alg><ol><li>Let <var>result</var> be the empty String.</li><li>For each element <var>next</var> of <var>codeUnits</var>, do<ol><li>Let <var>nextCU</var> be the code unit whose numeric value is <emu-xref aoid="ℝ" id="_ref_11286"><a href="notational-conventions.html#%E2%84%9D">ℝ</a></emu-xref>(? <emu-xref aoid="ToUint16" id="_ref_11287"><a href="abstract-operations.html#sec-touint16" class="e-user-code">ToUint16</a></emu-xref>(<var>next</var>)).</li><li>Set <var>result</var> to the <emu-xref href="#string-concatenation" id="_ref_11288"><a href="ecmascript-data-types-and-values.html#string-concatenation">string-concatenation</a></emu-xref> of <var>result</var> and <var>nextCU</var>.</li></ol></li><li>Return <var>result</var>.</li></ol></emu-alg>
|
||
<p>The <emu-val>"length"</emu-val> property of this function is <emu-val>1</emu-val><sub>𝔽</sub>.</p>
|
||
</emu-clause>
|
||
|
||
<emu-clause id="sec-string.fromcodepoint" type="built-in function">
|
||
<h1><span class="secnum">22.1.2.2</span> String.fromCodePoint ( ...<var>codePoints</var> )</h1>
|
||
<p>This function may be called with any number of arguments which form the rest parameter <var>codePoints</var>.</p>
|
||
<p>It performs the following steps when called:</p>
|
||
<emu-alg><ol><li>Let <var>result</var> be the empty String.</li><li>For each element <var>next</var> of <var>codePoints</var>, do<ol><li>Let <var>nextCP</var> be ? <emu-xref aoid="ToNumber" id="_ref_11289"><a href="abstract-operations.html#sec-tonumber" class="e-user-code">ToNumber</a></emu-xref>(<var>next</var>).</li><li>If <var>nextCP</var> is not an <emu-xref href="#integral-number" id="_ref_11290"><a href="notational-conventions.html#integral-number">integral Number</a></emu-xref>, throw a <emu-val>RangeError</emu-val> exception.</li><li>If <emu-xref aoid="ℝ" id="_ref_11291"><a href="notational-conventions.html#%E2%84%9D">ℝ</a></emu-xref>(<var>nextCP</var>) < 0 or <emu-xref aoid="ℝ" id="_ref_11292"><a href="notational-conventions.html#%E2%84%9D">ℝ</a></emu-xref>(<var>nextCP</var>) > 0x10FFFF, throw a <emu-val>RangeError</emu-val> exception.</li><li>Set <var>result</var> to the <emu-xref href="#string-concatenation" id="_ref_11293"><a href="ecmascript-data-types-and-values.html#string-concatenation">string-concatenation</a></emu-xref> of <var>result</var> and <emu-xref aoid="UTF16EncodeCodePoint" id="_ref_11294"><a href="ecmascript-language-source-code.html#sec-utf16encodecodepoint">UTF16EncodeCodePoint</a></emu-xref>(<emu-xref aoid="ℝ" id="_ref_11295"><a href="notational-conventions.html#%E2%84%9D">ℝ</a></emu-xref>(<var>nextCP</var>)).</li></ol></li><li><emu-xref href="#assert" id="_ref_11296"><a href="notational-conventions.html#assert">Assert</a></emu-xref>: If <var>codePoints</var> is empty, then <var>result</var> is the empty String.</li><li>Return <var>result</var>.</li></ol></emu-alg>
|
||
<p>The <emu-val>"length"</emu-val> property of this function is <emu-val>1</emu-val><sub>𝔽</sub>.</p>
|
||
</emu-clause>
|
||
|
||
<emu-clause id="sec-string.prototype">
|
||
<h1><span class="secnum">22.1.2.3</span> String.prototype</h1>
|
||
<p>The initial value of <code>String.prototype</code> is the <emu-xref href="#sec-properties-of-the-string-prototype-object" id="_ref_11297"><a href="text-processing.html#sec-properties-of-the-string-prototype-object">String prototype object</a></emu-xref>.</p>
|
||
<p>This property has the attributes { <var class="field">[[Writable]]</var>: <emu-val>false</emu-val>, <var class="field">[[Enumerable]]</var>: <emu-val>false</emu-val>, <var class="field">[[Configurable]]</var>: <emu-val>false</emu-val> }.</p>
|
||
</emu-clause>
|
||
|
||
<emu-clause id="sec-string.raw" type="built-in function">
|
||
<h1><span class="secnum">22.1.2.4</span> String.raw ( <var>template</var>, ...<var>substitutions</var> )</h1>
|
||
<p>This function may be called with a variable number of arguments. The first argument is <var>template</var> and the remainder of the arguments form the <emu-xref href="#sec-list-and-record-specification-type" id="_ref_11298"><a href="ecmascript-data-types-and-values.html#sec-list-and-record-specification-type">List</a></emu-xref> <var>substitutions</var>.</p>
|
||
<p>It performs the following steps when called:</p>
|
||
<emu-alg><ol><li>Let <var>substitutionCount</var> be the number of elements in <var>substitutions</var>.</li><li>Let <var>cooked</var> be ? <emu-xref aoid="ToObject" id="_ref_11299"><a href="abstract-operations.html#sec-toobject">ToObject</a></emu-xref>(<var>template</var>).</li><li>Let <var>literals</var> be ? <emu-xref aoid="ToObject" id="_ref_11300"><a href="abstract-operations.html#sec-toobject">ToObject</a></emu-xref>(? <emu-xref aoid="Get" id="_ref_11301"><a href="abstract-operations.html#sec-get-o-p" class="e-user-code">Get</a></emu-xref>(<var>cooked</var>, <emu-val>"raw"</emu-val>)).</li><li>Let <var>literalCount</var> be ? <emu-xref aoid="LengthOfArrayLike" id="_ref_11302"><a href="abstract-operations.html#sec-lengthofarraylike" class="e-user-code">LengthOfArrayLike</a></emu-xref>(<var>literals</var>).</li><li>If <var>literalCount</var> ≤ 0, return the empty String.</li><li>Let <var>R</var> be the empty String.</li><li>Let <var>nextIndex</var> be 0.</li><li>Repeat,<ol><li>Let <var>nextLiteralVal</var> be ? <emu-xref aoid="Get" id="_ref_11303"><a href="abstract-operations.html#sec-get-o-p" class="e-user-code">Get</a></emu-xref>(<var>literals</var>, ! <emu-xref aoid="ToString" id="_ref_11304"><a href="abstract-operations.html#sec-tostring">ToString</a></emu-xref>(<emu-xref aoid="𝔽" id="_ref_11305"><a href="notational-conventions.html#%F0%9D%94%BD">𝔽</a></emu-xref>(<var>nextIndex</var>))).</li><li>Let <var>nextLiteral</var> be ? <emu-xref aoid="ToString" id="_ref_11306"><a href="abstract-operations.html#sec-tostring" class="e-user-code">ToString</a></emu-xref>(<var>nextLiteralVal</var>).</li><li>Set <var>R</var> to the <emu-xref href="#string-concatenation" id="_ref_11307"><a href="ecmascript-data-types-and-values.html#string-concatenation">string-concatenation</a></emu-xref> of <var>R</var> and <var>nextLiteral</var>.</li><li>If <var>nextIndex</var> + 1 = <var>literalCount</var>, return <var>R</var>.</li><li>If <var>nextIndex</var> < <var>substitutionCount</var>, then<ol><li>Let <var>nextSubVal</var> be <var>substitutions</var>[<var>nextIndex</var>].</li><li>Let <var>nextSub</var> be ? <emu-xref aoid="ToString" id="_ref_11308"><a href="abstract-operations.html#sec-tostring" class="e-user-code">ToString</a></emu-xref>(<var>nextSubVal</var>).</li><li>Set <var>R</var> to the <emu-xref href="#string-concatenation" id="_ref_11309"><a href="ecmascript-data-types-and-values.html#string-concatenation">string-concatenation</a></emu-xref> of <var>R</var> and <var>nextSub</var>.</li></ol></li><li>Set <var>nextIndex</var> to <var>nextIndex</var> + 1.</li></ol></li></ol></emu-alg>
|
||
<emu-note><span class="note">Note</span><div class="note-contents">
|
||
<p>This function is intended for use as a tag function of a Tagged Template (<emu-xref href="#sec-tagged-templates" id="_ref_660"><a href="ecmascript-language-expressions.html#sec-tagged-templates">13.3.11</a></emu-xref>). When called as such, the first argument will be a well formed template object and the rest parameter will contain the substitution values.</p>
|
||
</div></emu-note>
|
||
</emu-clause>
|
||
</emu-clause>
|
||
|
||
<emu-clause id="sec-properties-of-the-string-prototype-object">
|
||
<h1><span class="secnum">22.1.3</span> Properties of the String Prototype Object</h1>
|
||
<p>The <dfn tabindex="-1">String prototype object</dfn>:</p>
|
||
<ul>
|
||
<li>is <dfn tabindex="-1">%String.prototype%</dfn>.</li>
|
||
<li><emu-xref href="#sec-ecmascript-language-types-string-type" id="_ref_11310"><a href="ecmascript-data-types-and-values.html#sec-ecmascript-language-types-string-type">is a String</a></emu-xref> <emu-xref href="#exotic-object" id="_ref_11311"><a href="ecmascript-data-types-and-values.html#exotic-object">exotic object</a></emu-xref> and has the internal methods specified for such objects.</li>
|
||
<li>has a <var class="field">[[StringData]]</var> internal slot whose value is the empty String.</li>
|
||
<li>has a <emu-val>"length"</emu-val> property whose initial value is <emu-val>+0</emu-val><sub>𝔽</sub> and whose attributes are { <var class="field">[[Writable]]</var>: <emu-val>false</emu-val>, <var class="field">[[Enumerable]]</var>: <emu-val>false</emu-val>, <var class="field">[[Configurable]]</var>: <emu-val>false</emu-val> }.</li>
|
||
<li>has a <var class="field">[[Prototype]]</var> internal slot whose value is <emu-xref href="#sec-properties-of-the-object-prototype-object" id="_ref_11312"><a href="fundamental-objects.html#sec-properties-of-the-object-prototype-object">%Object.prototype%</a></emu-xref>.</li>
|
||
</ul>
|
||
<p>Unless explicitly stated otherwise, the methods of the String prototype object defined below are not generic and the <emu-val>this</emu-val> value passed to them must be either a String value or an object that has a <var class="field">[[StringData]]</var> internal slot that has been initialized to a String value.</p>
|
||
|
||
<emu-clause id="sec-string.prototype.at" type="built-in function">
|
||
<h1><span class="secnum">22.1.3.1</span> String.prototype.at ( <var>index</var> )</h1>
|
||
<emu-alg><ol><li>Let <var>O</var> be the <emu-val>this</emu-val> value.</li><li>Perform ? <emu-xref aoid="RequireObjectCoercible" id="_ref_11313"><a href="abstract-operations.html#sec-requireobjectcoercible">RequireObjectCoercible</a></emu-xref>(<var>O</var>).</li><li>Let <var>S</var> be ? <emu-xref aoid="ToString" id="_ref_11314"><a href="abstract-operations.html#sec-tostring" class="e-user-code">ToString</a></emu-xref>(<var>O</var>).</li><li>Let <var>len</var> be the length of <var>S</var>.</li><li>Let <var>relativeIndex</var> be ? <emu-xref aoid="ToIntegerOrInfinity" id="_ref_11315"><a href="abstract-operations.html#sec-tointegerorinfinity" class="e-user-code">ToIntegerOrInfinity</a></emu-xref>(<var>index</var>).</li><li>If <var>relativeIndex</var> ≥ 0, then<ol><li>Let <var>k</var> be <var>relativeIndex</var>.</li></ol></li><li>Else,<ol><li>Let <var>k</var> be <var>len</var> + <var>relativeIndex</var>.</li></ol></li><li>If <var>k</var> < 0 or <var>k</var> ≥ <var>len</var>, return <emu-val>undefined</emu-val>.</li><li>Return the <emu-xref href="#substring" id="_ref_11316"><a href="ecmascript-data-types-and-values.html#substring">substring</a></emu-xref> of <var>S</var> from <var>k</var> to <var>k</var> + 1.</li></ol></emu-alg>
|
||
</emu-clause>
|
||
|
||
<emu-clause id="sec-string.prototype.charat" type="built-in function">
|
||
<h1><span class="secnum">22.1.3.2</span> String.prototype.charAt ( <var>pos</var> )</h1>
|
||
<emu-note><span class="note">Note 1</span><div class="note-contents">
|
||
<p>This method returns a single element String containing the code unit at index <var>pos</var> within the String value resulting from converting this object to a String. If there is no element at that index, the result is the empty String. The result <emu-xref href="#sec-ecmascript-language-types-string-type" id="_ref_11317"><a href="ecmascript-data-types-and-values.html#sec-ecmascript-language-types-string-type">is a String</a></emu-xref> value, not a String object.</p>
|
||
<p>If <code>pos</code> is an <emu-xref href="#integral-number" id="_ref_11318"><a href="notational-conventions.html#integral-number">integral Number</a></emu-xref>, then the result of <code>x.charAt(pos)</code> is equivalent to the result of <code>x.substring(pos, pos + 1)</code>.</p>
|
||
</div></emu-note>
|
||
<p>This method performs the following steps when called:</p>
|
||
<emu-alg><ol><li>Let <var>O</var> be the <emu-val>this</emu-val> value.</li><li>Perform ? <emu-xref aoid="RequireObjectCoercible" id="_ref_11319"><a href="abstract-operations.html#sec-requireobjectcoercible">RequireObjectCoercible</a></emu-xref>(<var>O</var>).</li><li>Let <var>S</var> be ? <emu-xref aoid="ToString" id="_ref_11320"><a href="abstract-operations.html#sec-tostring" class="e-user-code">ToString</a></emu-xref>(<var>O</var>).</li><li>Let <var>position</var> be ? <emu-xref aoid="ToIntegerOrInfinity" id="_ref_11321"><a href="abstract-operations.html#sec-tointegerorinfinity" class="e-user-code">ToIntegerOrInfinity</a></emu-xref>(<var>pos</var>).</li><li>Let <var>size</var> be the length of <var>S</var>.</li><li>If <var>position</var> < 0 or <var>position</var> ≥ <var>size</var>, return the empty String.</li><li>Return the <emu-xref href="#substring" id="_ref_11322"><a href="ecmascript-data-types-and-values.html#substring">substring</a></emu-xref> of <var>S</var> from <var>position</var> to <var>position</var> + 1.</li></ol></emu-alg>
|
||
<emu-note><span class="note">Note 2</span><div class="note-contents">
|
||
<p>This method is intentionally generic; it does not require that its <emu-val>this</emu-val> value be a String object. Therefore, it can be transferred to other kinds of objects for use as a method.</p>
|
||
</div></emu-note>
|
||
</emu-clause>
|
||
|
||
<emu-clause id="sec-string.prototype.charcodeat" type="built-in function">
|
||
<h1><span class="secnum">22.1.3.3</span> String.prototype.charCodeAt ( <var>pos</var> )</h1>
|
||
<emu-note><span class="note">Note 1</span><div class="note-contents">
|
||
<p>This method returns a Number (a non-negative <emu-xref href="#integral-number" id="_ref_11323"><a href="notational-conventions.html#integral-number">integral Number</a></emu-xref> less than 2<sup>16</sup>) that is the numeric value of the code unit at index <var>pos</var> within the String resulting from converting this object to a String. If there is no element at that index, the result is <emu-val>NaN</emu-val>.</p>
|
||
</div></emu-note>
|
||
<p>This method performs the following steps when called:</p>
|
||
<emu-alg><ol><li>Let <var>O</var> be the <emu-val>this</emu-val> value.</li><li>Perform ? <emu-xref aoid="RequireObjectCoercible" id="_ref_11324"><a href="abstract-operations.html#sec-requireobjectcoercible">RequireObjectCoercible</a></emu-xref>(<var>O</var>).</li><li>Let <var>S</var> be ? <emu-xref aoid="ToString" id="_ref_11325"><a href="abstract-operations.html#sec-tostring" class="e-user-code">ToString</a></emu-xref>(<var>O</var>).</li><li>Let <var>position</var> be ? <emu-xref aoid="ToIntegerOrInfinity" id="_ref_11326"><a href="abstract-operations.html#sec-tointegerorinfinity" class="e-user-code">ToIntegerOrInfinity</a></emu-xref>(<var>pos</var>).</li><li>Let <var>size</var> be the length of <var>S</var>.</li><li>If <var>position</var> < 0 or <var>position</var> ≥ <var>size</var>, return <emu-val>NaN</emu-val>.</li><li>Return the <emu-xref href="#number-value-for" id="_ref_11327"><a href="ecmascript-data-types-and-values.html#number-value-for">Number value for</a></emu-xref> the numeric value of the code unit at index <var>position</var> within the String <var>S</var>.</li></ol></emu-alg>
|
||
<emu-note><span class="note">Note 2</span><div class="note-contents">
|
||
<p>This method is intentionally generic; it does not require that its <emu-val>this</emu-val> value be a String object. Therefore it can be transferred to other kinds of objects for use as a method.</p>
|
||
</div></emu-note>
|
||
</emu-clause>
|
||
|
||
<emu-clause id="sec-string.prototype.codepointat" type="built-in function">
|
||
<h1><span class="secnum">22.1.3.4</span> String.prototype.codePointAt ( <var>pos</var> )</h1>
|
||
<emu-note><span class="note">Note 1</span><div class="note-contents">
|
||
<p>This method returns a non-negative <emu-xref href="#integral-number" id="_ref_11328"><a href="notational-conventions.html#integral-number">integral Number</a></emu-xref> less than or equal to <emu-val>0x10FFFF</emu-val><sub>𝔽</sub> that is the numeric value of the UTF-16 encoded code point (<emu-xref href="#sec-ecmascript-language-types-string-type" id="_ref_661"><a href="ecmascript-data-types-and-values.html#sec-ecmascript-language-types-string-type">6.1.4</a></emu-xref>) starting at the string element at index <var>pos</var> within the String resulting from converting this object to a String. If there is no element at that index, the result is <emu-val>undefined</emu-val>. If a valid UTF-16 <emu-xref href="#surrogate-pair" id="_ref_11329"><a href="ecmascript-data-types-and-values.html#surrogate-pair">surrogate pair</a></emu-xref> does not begin at <var>pos</var>, the result is the code unit at <var>pos</var>.</p>
|
||
</div></emu-note>
|
||
<p>This method performs the following steps when called:</p>
|
||
<emu-alg><ol><li>Let <var>O</var> be the <emu-val>this</emu-val> value.</li><li>Perform ? <emu-xref aoid="RequireObjectCoercible" id="_ref_11330"><a href="abstract-operations.html#sec-requireobjectcoercible">RequireObjectCoercible</a></emu-xref>(<var>O</var>).</li><li>Let <var>S</var> be ? <emu-xref aoid="ToString" id="_ref_11331"><a href="abstract-operations.html#sec-tostring" class="e-user-code">ToString</a></emu-xref>(<var>O</var>).</li><li>Let <var>position</var> be ? <emu-xref aoid="ToIntegerOrInfinity" id="_ref_11332"><a href="abstract-operations.html#sec-tointegerorinfinity" class="e-user-code">ToIntegerOrInfinity</a></emu-xref>(<var>pos</var>).</li><li>Let <var>size</var> be the length of <var>S</var>.</li><li>If <var>position</var> < 0 or <var>position</var> ≥ <var>size</var>, return <emu-val>undefined</emu-val>.</li><li>Let <var>cp</var> be <emu-xref aoid="CodePointAt" id="_ref_11333"><a href="ecmascript-language-source-code.html#sec-codepointat">CodePointAt</a></emu-xref>(<var>S</var>, <var>position</var>).</li><li>Return <emu-xref aoid="𝔽" id="_ref_11334"><a href="notational-conventions.html#%F0%9D%94%BD">𝔽</a></emu-xref>(<var>cp</var>.<var class="field">[[CodePoint]]</var>).</li></ol></emu-alg>
|
||
<emu-note><span class="note">Note 2</span><div class="note-contents">
|
||
<p>This method is intentionally generic; it does not require that its <emu-val>this</emu-val> value be a String object. Therefore it can be transferred to other kinds of objects for use as a method.</p>
|
||
</div></emu-note>
|
||
</emu-clause>
|
||
|
||
<emu-clause id="sec-string.prototype.concat" type="built-in function">
|
||
<h1><span class="secnum">22.1.3.5</span> String.prototype.concat ( ...<var>args</var> )</h1>
|
||
<emu-note><span class="note">Note 1</span><div class="note-contents">
|
||
<p>When this method is called it returns the String value consisting of the code units of the <emu-val>this</emu-val> value (converted to a String) followed by the code units of each of the arguments converted to a String. The result <emu-xref href="#sec-ecmascript-language-types-string-type" id="_ref_11335"><a href="ecmascript-data-types-and-values.html#sec-ecmascript-language-types-string-type">is a String</a></emu-xref> value, not a String object.</p>
|
||
</div></emu-note>
|
||
<p>This method performs the following steps when called:</p>
|
||
<emu-alg><ol><li>Let <var>O</var> be the <emu-val>this</emu-val> value.</li><li>Perform ? <emu-xref aoid="RequireObjectCoercible" id="_ref_11336"><a href="abstract-operations.html#sec-requireobjectcoercible">RequireObjectCoercible</a></emu-xref>(<var>O</var>).</li><li>Let <var>S</var> be ? <emu-xref aoid="ToString" id="_ref_11337"><a href="abstract-operations.html#sec-tostring" class="e-user-code">ToString</a></emu-xref>(<var>O</var>).</li><li>Let <var>R</var> be <var>S</var>.</li><li>For each element <var>next</var> of <var>args</var>, do<ol><li>Let <var>nextString</var> be ? <emu-xref aoid="ToString" id="_ref_11338"><a href="abstract-operations.html#sec-tostring" class="e-user-code">ToString</a></emu-xref>(<var>next</var>).</li><li>Set <var>R</var> to the <emu-xref href="#string-concatenation" id="_ref_11339"><a href="ecmascript-data-types-and-values.html#string-concatenation">string-concatenation</a></emu-xref> of <var>R</var> and <var>nextString</var>.</li></ol></li><li>Return <var>R</var>.</li></ol></emu-alg>
|
||
<p>The <emu-val>"length"</emu-val> property of this method is <emu-val>1</emu-val><sub>𝔽</sub>.</p>
|
||
<emu-note><span class="note">Note 2</span><div class="note-contents">
|
||
<p>This method is intentionally generic; it does not require that its <emu-val>this</emu-val> value be a String object. Therefore it can be transferred to other kinds of objects for use as a method.</p>
|
||
</div></emu-note>
|
||
</emu-clause>
|
||
|
||
<emu-clause id="sec-string.prototype.constructor">
|
||
<h1><span class="secnum">22.1.3.6</span> String.prototype.constructor</h1>
|
||
<p>The initial value of <code>String.prototype.constructor</code> is <emu-xref href="#sec-string-constructor" id="_ref_11340"><a href="text-processing.html#sec-string-constructor">%String%</a></emu-xref>.</p>
|
||
</emu-clause>
|
||
|
||
<emu-clause id="sec-string.prototype.endswith" type="built-in function">
|
||
<h1><span class="secnum">22.1.3.7</span> String.prototype.endsWith ( <var>searchString</var> [ , <var>endPosition</var> ] )</h1>
|
||
<p>This method performs the following steps when called:</p>
|
||
<emu-alg><ol><li>Let <var>O</var> be the <emu-val>this</emu-val> value.</li><li>Perform ? <emu-xref aoid="RequireObjectCoercible" id="_ref_11341"><a href="abstract-operations.html#sec-requireobjectcoercible">RequireObjectCoercible</a></emu-xref>(<var>O</var>).</li><li>Let <var>S</var> be ? <emu-xref aoid="ToString" id="_ref_11342"><a href="abstract-operations.html#sec-tostring" class="e-user-code">ToString</a></emu-xref>(<var>O</var>).</li><li>Let <var>isRegExp</var> be ? <emu-xref aoid="IsRegExp" id="_ref_11343"><a href="abstract-operations.html#sec-isregexp" class="e-user-code">IsRegExp</a></emu-xref>(<var>searchString</var>).</li><li>If <var>isRegExp</var> is <emu-val>true</emu-val>, throw a <emu-val>TypeError</emu-val> exception.</li><li>Let <var>searchStr</var> be ? <emu-xref aoid="ToString" id="_ref_11344"><a href="abstract-operations.html#sec-tostring" class="e-user-code">ToString</a></emu-xref>(<var>searchString</var>).</li><li>Let <var>len</var> be the length of <var>S</var>.</li><li>If <var>endPosition</var> is <emu-val>undefined</emu-val>, let <var>pos</var> be <var>len</var>; else let <var>pos</var> be ? <emu-xref aoid="ToIntegerOrInfinity" id="_ref_11345"><a href="abstract-operations.html#sec-tointegerorinfinity" class="e-user-code">ToIntegerOrInfinity</a></emu-xref>(<var>endPosition</var>).</li><li>Let <var>end</var> be the result of <emu-xref href="#clamping" id="_ref_11346"><a href="notational-conventions.html#clamping">clamping</a></emu-xref> <var>pos</var> between 0 and <var>len</var>.</li><li>Let <var>searchLength</var> be the length of <var>searchStr</var>.</li><li>If <var>searchLength</var> = 0, return <emu-val>true</emu-val>.</li><li>Let <var>start</var> be <var>end</var> - <var>searchLength</var>.</li><li>If <var>start</var> < 0, return <emu-val>false</emu-val>.</li><li>Let <var>substring</var> be the <emu-xref href="#substring" id="_ref_11347"><a href="ecmascript-data-types-and-values.html#substring">substring</a></emu-xref> of <var>S</var> from <var>start</var> to <var>end</var>.</li><li>If <var>substring</var> is <var>searchStr</var>, return <emu-val>true</emu-val>.</li><li>Return <emu-val>false</emu-val>.</li></ol></emu-alg>
|
||
<emu-note><span class="note">Note 1</span><div class="note-contents">
|
||
<p>This method returns <emu-val>true</emu-val> if the sequence of code units of <var>searchString</var> converted to a String is the same as the corresponding code units of this object (converted to a String) starting at <var>endPosition</var> - length(this). Otherwise it returns <emu-val>false</emu-val>.</p>
|
||
</div></emu-note>
|
||
<emu-note><span class="note">Note 2</span><div class="note-contents">
|
||
<p>Throwing an exception if the first argument is a RegExp is specified in order to allow future editions to define extensions that allow such argument values.</p>
|
||
</div></emu-note>
|
||
<emu-note><span class="note">Note 3</span><div class="note-contents">
|
||
<p>This method is intentionally generic; it does not require that its <emu-val>this</emu-val> value be a String object. Therefore, it can be transferred to other kinds of objects for use as a method.</p>
|
||
</div></emu-note>
|
||
</emu-clause>
|
||
|
||
<emu-clause id="sec-string.prototype.includes" type="built-in function">
|
||
<h1><span class="secnum">22.1.3.8</span> String.prototype.includes ( <var>searchString</var> [ , <var>position</var> ] )</h1>
|
||
<p>This method performs the following steps when called:</p>
|
||
<emu-alg><ol><li>Let <var>O</var> be the <emu-val>this</emu-val> value.</li><li>Perform ? <emu-xref aoid="RequireObjectCoercible" id="_ref_11348"><a href="abstract-operations.html#sec-requireobjectcoercible">RequireObjectCoercible</a></emu-xref>(<var>O</var>).</li><li>Let <var>S</var> be ? <emu-xref aoid="ToString" id="_ref_11349"><a href="abstract-operations.html#sec-tostring" class="e-user-code">ToString</a></emu-xref>(<var>O</var>).</li><li>Let <var>isRegExp</var> be ? <emu-xref aoid="IsRegExp" id="_ref_11350"><a href="abstract-operations.html#sec-isregexp" class="e-user-code">IsRegExp</a></emu-xref>(<var>searchString</var>).</li><li>If <var>isRegExp</var> is <emu-val>true</emu-val>, throw a <emu-val>TypeError</emu-val> exception.</li><li>Let <var>searchStr</var> be ? <emu-xref aoid="ToString" id="_ref_11351"><a href="abstract-operations.html#sec-tostring" class="e-user-code">ToString</a></emu-xref>(<var>searchString</var>).</li><li>Let <var>pos</var> be ? <emu-xref aoid="ToIntegerOrInfinity" id="_ref_11352"><a href="abstract-operations.html#sec-tointegerorinfinity" class="e-user-code">ToIntegerOrInfinity</a></emu-xref>(<var>position</var>).</li><li><emu-xref href="#assert" id="_ref_11353"><a href="notational-conventions.html#assert">Assert</a></emu-xref>: If <var>position</var> is <emu-val>undefined</emu-val>, then <var>pos</var> is 0.</li><li>Let <var>len</var> be the length of <var>S</var>.</li><li>Let <var>start</var> be the result of <emu-xref href="#clamping" id="_ref_11354"><a href="notational-conventions.html#clamping">clamping</a></emu-xref> <var>pos</var> between 0 and <var>len</var>.</li><li>Let <var>index</var> be <emu-xref aoid="StringIndexOf" id="_ref_11355"><a href="ecmascript-data-types-and-values.html#sec-stringindexof">StringIndexOf</a></emu-xref>(<var>S</var>, <var>searchStr</var>, <var>start</var>).</li><li>If <var>index</var> is <emu-const>not-found</emu-const>, return <emu-val>false</emu-val>.</li><li>Return <emu-val>true</emu-val>.</li></ol></emu-alg>
|
||
<emu-note><span class="note">Note 1</span><div class="note-contents">
|
||
<p>If <var>searchString</var> appears as a <emu-not-ref>substring</emu-not-ref> of the result of converting this object to a String, at one or more indices that are greater than or equal to <var>position</var>, this function returns <emu-val>true</emu-val>; otherwise, it returns <emu-val>false</emu-val>. If <var>position</var> is <emu-val>undefined</emu-val>, 0 is assumed, so as to search all of the String.</p>
|
||
</div></emu-note>
|
||
<emu-note><span class="note">Note 2</span><div class="note-contents">
|
||
<p>Throwing an exception if the first argument is a RegExp is specified in order to allow future editions to define extensions that allow such argument values.</p>
|
||
</div></emu-note>
|
||
<emu-note><span class="note">Note 3</span><div class="note-contents">
|
||
<p>This method is intentionally generic; it does not require that its <emu-val>this</emu-val> value be a String object. Therefore, it can be transferred to other kinds of objects for use as a method.</p>
|
||
</div></emu-note>
|
||
</emu-clause>
|
||
|
||
<emu-clause id="sec-string.prototype.indexof" type="built-in function">
|
||
<h1><span class="secnum">22.1.3.9</span> String.prototype.indexOf ( <var>searchString</var> [ , <var>position</var> ] )</h1>
|
||
<emu-note><span class="note">Note 1</span><div class="note-contents">
|
||
<p>If <var>searchString</var> appears as a <emu-not-ref>substring</emu-not-ref> of the result of converting this object to a String, at one or more indices that are greater than or equal to <var>position</var>, then the smallest such index is returned; otherwise, <emu-val>-1</emu-val><sub>𝔽</sub> is returned. If <var>position</var> is <emu-val>undefined</emu-val>, <emu-val>+0</emu-val><sub>𝔽</sub> is assumed, so as to search all of the String.</p>
|
||
</div></emu-note>
|
||
<p>This method performs the following steps when called:</p>
|
||
<emu-alg><ol><li>Let <var>O</var> be the <emu-val>this</emu-val> value.</li><li>Perform ? <emu-xref aoid="RequireObjectCoercible" id="_ref_11356"><a href="abstract-operations.html#sec-requireobjectcoercible">RequireObjectCoercible</a></emu-xref>(<var>O</var>).</li><li>Let <var>S</var> be ? <emu-xref aoid="ToString" id="_ref_11357"><a href="abstract-operations.html#sec-tostring" class="e-user-code">ToString</a></emu-xref>(<var>O</var>).</li><li>Let <var>searchStr</var> be ? <emu-xref aoid="ToString" id="_ref_11358"><a href="abstract-operations.html#sec-tostring" class="e-user-code">ToString</a></emu-xref>(<var>searchString</var>).</li><li>Let <var>pos</var> be ? <emu-xref aoid="ToIntegerOrInfinity" id="_ref_11359"><a href="abstract-operations.html#sec-tointegerorinfinity" class="e-user-code">ToIntegerOrInfinity</a></emu-xref>(<var>position</var>).</li><li><emu-xref href="#assert" id="_ref_11360"><a href="notational-conventions.html#assert">Assert</a></emu-xref>: If <var>position</var> is <emu-val>undefined</emu-val>, then <var>pos</var> is 0.</li><li>Let <var>len</var> be the length of <var>S</var>.</li><li>Let <var>start</var> be the result of <emu-xref href="#clamping" id="_ref_11361"><a href="notational-conventions.html#clamping">clamping</a></emu-xref> <var>pos</var> between 0 and <var>len</var>.</li><li>Let <var>result</var> be <emu-xref aoid="StringIndexOf" id="_ref_11362"><a href="ecmascript-data-types-and-values.html#sec-stringindexof">StringIndexOf</a></emu-xref>(<var>S</var>, <var>searchStr</var>, <var>start</var>).</li><li>If <var>result</var> is <emu-const>not-found</emu-const>, return <emu-val>-1</emu-val><sub>𝔽</sub>.</li><li>Return <emu-xref aoid="𝔽" id="_ref_11363"><a href="notational-conventions.html#%F0%9D%94%BD">𝔽</a></emu-xref>(<var>result</var>).</li></ol></emu-alg>
|
||
<emu-note><span class="note">Note 2</span><div class="note-contents">
|
||
<p>This method is intentionally generic; it does not require that its <emu-val>this</emu-val> value be a String object. Therefore, it can be transferred to other kinds of objects for use as a method.</p>
|
||
</div></emu-note>
|
||
</emu-clause>
|
||
|
||
<emu-clause id="sec-string.prototype.iswellformed" type="built-in function">
|
||
<h1><span class="secnum">22.1.3.10</span> String.prototype.isWellFormed ( )</h1>
|
||
<p>This method performs the following steps when called:</p>
|
||
<emu-alg><ol><li>Let <var>O</var> be the <emu-val>this</emu-val> value.</li><li>Perform ? <emu-xref aoid="RequireObjectCoercible" id="_ref_11364"><a href="abstract-operations.html#sec-requireobjectcoercible">RequireObjectCoercible</a></emu-xref>(<var>O</var>).</li><li>Let <var>S</var> be ? <emu-xref aoid="ToString" id="_ref_11365"><a href="abstract-operations.html#sec-tostring" class="e-user-code">ToString</a></emu-xref>(<var>O</var>).</li><li>Return <emu-xref aoid="IsStringWellFormedUnicode" id="_ref_11366"><a href="abstract-operations.html#sec-isstringwellformedunicode">IsStringWellFormedUnicode</a></emu-xref>(<var>S</var>).</li></ol></emu-alg>
|
||
</emu-clause>
|
||
|
||
<emu-clause id="sec-string.prototype.lastindexof" type="built-in function">
|
||
<h1><span class="secnum">22.1.3.11</span> String.prototype.lastIndexOf ( <var>searchString</var> [ , <var>position</var> ] )</h1>
|
||
<emu-note><span class="note">Note 1</span><div class="note-contents">
|
||
<p>If <var>searchString</var> appears as a <emu-not-ref>substring</emu-not-ref> of the result of converting this object to a String at one or more indices that are smaller than or equal to <var>position</var>, then the greatest such index is returned; otherwise, <emu-val>-1</emu-val><sub>𝔽</sub> is returned. If <var>position</var> is <emu-val>undefined</emu-val>, the length of the String value is assumed, so as to search all of the String.</p>
|
||
</div></emu-note>
|
||
<p>This method performs the following steps when called:</p>
|
||
<emu-alg><ol><li>Let <var>O</var> be the <emu-val>this</emu-val> value.</li><li>Perform ? <emu-xref aoid="RequireObjectCoercible" id="_ref_11367"><a href="abstract-operations.html#sec-requireobjectcoercible">RequireObjectCoercible</a></emu-xref>(<var>O</var>).</li><li>Let <var>S</var> be ? <emu-xref aoid="ToString" id="_ref_11368"><a href="abstract-operations.html#sec-tostring" class="e-user-code">ToString</a></emu-xref>(<var>O</var>).</li><li>Let <var>searchStr</var> be ? <emu-xref aoid="ToString" id="_ref_11369"><a href="abstract-operations.html#sec-tostring" class="e-user-code">ToString</a></emu-xref>(<var>searchString</var>).</li><li>Let <var>numPos</var> be ? <emu-xref aoid="ToNumber" id="_ref_11370"><a href="abstract-operations.html#sec-tonumber" class="e-user-code">ToNumber</a></emu-xref>(<var>position</var>).</li><li><emu-xref href="#assert" id="_ref_11371"><a href="notational-conventions.html#assert">Assert</a></emu-xref>: If <var>position</var> is <emu-val>undefined</emu-val>, then <var>numPos</var> is <emu-val>NaN</emu-val>.</li><li>If <var>numPos</var> is <emu-val>NaN</emu-val>, let <var>pos</var> be +∞; else let <var>pos</var> be ! <emu-xref aoid="ToIntegerOrInfinity" id="_ref_11372"><a href="abstract-operations.html#sec-tointegerorinfinity">ToIntegerOrInfinity</a></emu-xref>(<var>numPos</var>).</li><li>Let <var>len</var> be the length of <var>S</var>.</li><li>Let <var>searchLen</var> be the length of <var>searchStr</var>.</li><li>If <var>len</var> < <var>searchLen</var>, return <emu-val>-1</emu-val><sub>𝔽</sub>.</li><li>Let <var>start</var> be the result of <emu-xref href="#clamping" id="_ref_11373"><a href="notational-conventions.html#clamping">clamping</a></emu-xref> <var>pos</var> between 0 and <var>len</var> - <var>searchLen</var>.</li><li>Let <var>result</var> be <emu-xref aoid="StringLastIndexOf" id="_ref_11374"><a href="ecmascript-data-types-and-values.html#sec-stringlastindexof">StringLastIndexOf</a></emu-xref>(<var>S</var>, <var>searchStr</var>, <var>start</var>).</li><li>If <var>result</var> is <emu-const>not-found</emu-const>, return <emu-val>-1</emu-val><sub>𝔽</sub>.</li><li>Return <emu-xref aoid="𝔽" id="_ref_11375"><a href="notational-conventions.html#%F0%9D%94%BD">𝔽</a></emu-xref>(<var>result</var>).</li></ol></emu-alg>
|
||
<emu-note><span class="note">Note 2</span><div class="note-contents">
|
||
<p>This method is intentionally generic; it does not require that its <emu-val>this</emu-val> value be a String object. Therefore, it can be transferred to other kinds of objects for use as a method.</p>
|
||
</div></emu-note>
|
||
</emu-clause>
|
||
|
||
<emu-clause id="sec-string.prototype.localecompare" type="built-in function">
|
||
<h1><span class="secnum">22.1.3.12</span> String.prototype.localeCompare ( <var>that</var> [ , <var>reserved1</var> [ , <var>reserved2</var> ] ] )</h1>
|
||
<p>An ECMAScript implementation that includes the ECMA-402 Internationalization API must implement this method as specified in the ECMA-402 specification. If an ECMAScript implementation does not include the ECMA-402 API the following specification of this method is used:</p>
|
||
<p>This method returns a Number other than <emu-val>NaN</emu-val> representing the result of an <emu-xref href="#implementation-defined" id="_ref_11376"><a href="overview.html#implementation-defined">implementation-defined</a></emu-xref> locale-sensitive String comparison of the <emu-val>this</emu-val> value (converted to a String <var>S</var>) with <var>that</var> (converted to a String <var>thatValue</var>). The result is intended to correspond with a <emu-xref href="#sort-order" id="_ref_11377"><a href="indexed-collections.html#sort-order">sort order</a></emu-xref> of String values according to conventions of the <emu-xref href="#host-environment" id="_ref_11378"><a href="overview.html#host-environment">host environment</a></emu-xref>'s current locale, and will be negative when <var>S</var> is ordered before <var>thatValue</var>, positive when <var>S</var> is ordered after <var>thatValue</var>, and zero in all other cases (representing no relative ordering between <var>S</var> and <var>thatValue</var>).</p>
|
||
<p>Before performing the comparisons, this method performs the following steps to prepare the Strings:</p>
|
||
<emu-alg><ol><li>Let <var>O</var> be the <emu-val>this</emu-val> value.</li><li>Perform ? <emu-xref aoid="RequireObjectCoercible" id="_ref_11379"><a href="abstract-operations.html#sec-requireobjectcoercible">RequireObjectCoercible</a></emu-xref>(<var>O</var>).</li><li>Let <var>S</var> be ? <emu-xref aoid="ToString" id="_ref_11380"><a href="abstract-operations.html#sec-tostring" class="e-user-code">ToString</a></emu-xref>(<var>O</var>).</li><li>Let <var>thatValue</var> be ? <emu-xref aoid="ToString" id="_ref_11381"><a href="abstract-operations.html#sec-tostring" class="e-user-code">ToString</a></emu-xref>(<var>that</var>).</li></ol></emu-alg>
|
||
<p>The meaning of the optional second and third parameters to this method are defined in the ECMA-402 specification; implementations that do not include ECMA-402 support must not assign any other interpretation to those parameter positions.</p>
|
||
<p>The actual return values are <emu-xref href="#implementation-defined" id="_ref_11382"><a href="overview.html#implementation-defined">implementation-defined</a></emu-xref> to permit encoding additional information in them, but this method, when considered as a method of two arguments, is required to be a <emu-xref href="#consistent-comparator" id="_ref_11383"><a href="indexed-collections.html#consistent-comparator">consistent comparator</a></emu-xref> defining a total ordering on the set of all Strings. This method is also required to recognize and honour canonical equivalence according to the Unicode Standard, including returning <emu-val>+0</emu-val><sub>𝔽</sub> when comparing distinguishable Strings that are canonically equivalent.</p>
|
||
<emu-note><span class="note">Note 1</span><div class="note-contents">
|
||
<p>This method itself is not directly suitable as an argument to <code>Array.prototype.sort</code> because the latter requires a function of two arguments.</p>
|
||
</div></emu-note>
|
||
<emu-note><span class="note">Note 2</span><div class="note-contents">
|
||
<p>This method may rely on whatever language- and/or locale-sensitive comparison functionality is available to the ECMAScript environment from the <emu-xref href="#host-environment" id="_ref_11384"><a href="overview.html#host-environment">host environment</a></emu-xref>, and is intended to compare according to the conventions of the <emu-xref href="#host-environment" id="_ref_11385"><a href="overview.html#host-environment">host environment</a></emu-xref>'s current locale. However, regardless of comparison capabilities, this method must recognize and honour canonical equivalence according to the Unicode Standard—for example, the following comparisons must all return <emu-val>+0</emu-val><sub>𝔽</sub>:</p>
|
||
<pre><code class="javascript hljs"><span class="hljs-comment">// Å ANGSTROM SIGN vs.</span>
|
||
<span class="hljs-comment">// Å LATIN CAPITAL LETTER A + COMBINING RING ABOVE</span>
|
||
<span class="hljs-string">"\u212B"</span>.<span class="hljs-title function_">localeCompare</span>(<span class="hljs-string">"A\u030A"</span>)
|
||
|
||
<span class="hljs-comment">// Ω OHM SIGN vs.</span>
|
||
<span class="hljs-comment">// Ω GREEK CAPITAL LETTER OMEGA</span>
|
||
<span class="hljs-string">"\u2126"</span>.<span class="hljs-title function_">localeCompare</span>(<span class="hljs-string">"\u03A9"</span>)
|
||
|
||
<span class="hljs-comment">// ṩ LATIN SMALL LETTER S WITH DOT BELOW AND DOT ABOVE vs.</span>
|
||
<span class="hljs-comment">// ṩ LATIN SMALL LETTER S + COMBINING DOT ABOVE + COMBINING DOT BELOW</span>
|
||
<span class="hljs-string">"\u1E69"</span>.<span class="hljs-title function_">localeCompare</span>(<span class="hljs-string">"s\u0307\u0323"</span>)
|
||
|
||
<span class="hljs-comment">// ḍ̇ LATIN SMALL LETTER D WITH DOT ABOVE + COMBINING DOT BELOW vs.</span>
|
||
<span class="hljs-comment">// ḍ̇ LATIN SMALL LETTER D WITH DOT BELOW + COMBINING DOT ABOVE</span>
|
||
<span class="hljs-string">"\u1E0B\u0323"</span>.<span class="hljs-title function_">localeCompare</span>(<span class="hljs-string">"\u1E0D\u0307"</span>)
|
||
|
||
<span class="hljs-comment">// 가 HANGUL CHOSEONG KIYEOK + HANGUL JUNGSEONG A vs.</span>
|
||
<span class="hljs-comment">// 가 HANGUL SYLLABLE GA</span>
|
||
<span class="hljs-string">"\u1100\u1161"</span>.<span class="hljs-title function_">localeCompare</span>(<span class="hljs-string">"\uAC00"</span>)</code></pre>
|
||
<p>For a definition and discussion of canonical equivalence see the Unicode Standard, chapters 2 and 3, as well as <a href="https://unicode.org/reports/tr15/">Unicode Standard Annex #15, Unicode Normalization Forms</a> and <a href="https://unicode.org/notes/tn5/">Unicode Technical Note #5, Canonical Equivalence in Applications</a>. Also see <a href="https://unicode.org/reports/tr10/">Unicode Technical Standard #10, Unicode Collation Algorithm</a>.</p>
|
||
<p>It is recommended that this method should not honour Unicode compatibility equivalents or compatibility decompositions as defined in the Unicode Standard, chapter 3, section 3.7.</p>
|
||
</div></emu-note>
|
||
<emu-note><span class="note">Note 3</span><div class="note-contents">
|
||
<p>This method is intentionally generic; it does not require that its <emu-val>this</emu-val> value be a String object. Therefore, it can be transferred to other kinds of objects for use as a method.</p>
|
||
</div></emu-note>
|
||
</emu-clause>
|
||
|
||
<emu-clause id="sec-string.prototype.match" type="built-in function">
|
||
<h1><span class="secnum">22.1.3.13</span> String.prototype.match ( <var>regexp</var> )</h1>
|
||
<p>This method performs the following steps when called:</p>
|
||
<emu-alg><ol><li>Let <var>O</var> be the <emu-val>this</emu-val> value.</li><li>Perform ? <emu-xref aoid="RequireObjectCoercible" id="_ref_11386"><a href="abstract-operations.html#sec-requireobjectcoercible">RequireObjectCoercible</a></emu-xref>(<var>O</var>).</li><li>If <var>regexp</var> <emu-xref href="#sec-object-type" id="_ref_11387"><a href="ecmascript-data-types-and-values.html#sec-object-type">is an Object</a></emu-xref>, then<ol><li>Let <var>matcher</var> be ? <emu-xref aoid="GetMethod" id="_ref_11388"><a href="abstract-operations.html#sec-getmethod" class="e-user-code">GetMethod</a></emu-xref>(<var>regexp</var>, <emu-xref href="#sec-well-known-symbols" id="_ref_11389"><a href="ecmascript-data-types-and-values.html#sec-well-known-symbols">%Symbol.match%</a></emu-xref>).</li><li>If <var>matcher</var> is not <emu-val>undefined</emu-val>, then<ol><li>Return ? <emu-xref aoid="Call" id="_ref_11390"><a href="abstract-operations.html#sec-call" class="e-user-code">Call</a></emu-xref>(<var>matcher</var>, <var>regexp</var>, « <var>O</var> »).</li></ol></li></ol></li><li>Let <var>S</var> be ? <emu-xref aoid="ToString" id="_ref_11391"><a href="abstract-operations.html#sec-tostring" class="e-user-code">ToString</a></emu-xref>(<var>O</var>).</li><li>Let <var>rx</var> be ? <emu-xref aoid="RegExpCreate" id="_ref_11392"><a href="text-processing.html#sec-regexpcreate" class="e-user-code">RegExpCreate</a></emu-xref>(<var>regexp</var>, <emu-val>undefined</emu-val>).</li><li>Return ? <emu-xref aoid="Invoke" id="_ref_11393"><a href="abstract-operations.html#sec-invoke" class="e-user-code">Invoke</a></emu-xref>(<var>rx</var>, <emu-xref href="#sec-well-known-symbols" id="_ref_11394"><a href="ecmascript-data-types-and-values.html#sec-well-known-symbols">%Symbol.match%</a></emu-xref>, « <var>S</var> »).</li></ol></emu-alg>
|
||
<emu-note><span class="note">Note</span><div class="note-contents">
|
||
<p>This method is intentionally generic; it does not require that its <emu-val>this</emu-val> value be a String object. Therefore, it can be transferred to other kinds of objects for use as a method.</p>
|
||
</div></emu-note>
|
||
</emu-clause>
|
||
|
||
<emu-clause id="sec-string.prototype.matchall" type="built-in function">
|
||
<h1><span class="secnum">22.1.3.14</span> String.prototype.matchAll ( <var>regexp</var> )</h1>
|
||
<p>This method performs a regular expression match of the String representing the <emu-val>this</emu-val> value against <var>regexp</var> and returns an <emu-xref href="#sec-iterator-interface" id="_ref_11395"><a href="control-abstraction-objects.html#sec-iterator-interface">iterator</a></emu-xref> that yields match results. Each match result is an Array containing the matched portion of the String as the first element, followed by the portions matched by any capturing groups. If the regular expression never matches, the returned <emu-xref href="#sec-iterator-interface" id="_ref_11396"><a href="control-abstraction-objects.html#sec-iterator-interface">iterator</a></emu-xref> does not yield any match results.</p>
|
||
<p>It performs the following steps when called:</p>
|
||
|
||
<emu-alg><ol><li>Let <var>O</var> be the <emu-val>this</emu-val> value.</li><li>Perform ? <emu-xref aoid="RequireObjectCoercible" id="_ref_11397"><a href="abstract-operations.html#sec-requireobjectcoercible">RequireObjectCoercible</a></emu-xref>(<var>O</var>).</li><li>If <var>regexp</var> <emu-xref href="#sec-object-type" id="_ref_11398"><a href="ecmascript-data-types-and-values.html#sec-object-type">is an Object</a></emu-xref>, then<ol><li>Let <var>isRegExp</var> be ? <emu-xref aoid="IsRegExp" id="_ref_11399"><a href="abstract-operations.html#sec-isregexp" class="e-user-code">IsRegExp</a></emu-xref>(<var>regexp</var>).</li><li>If <var>isRegExp</var> is <emu-val>true</emu-val>, then<ol><li>Let <var>flags</var> be ? <emu-xref aoid="Get" id="_ref_11400"><a href="abstract-operations.html#sec-get-o-p" class="e-user-code">Get</a></emu-xref>(<var>regexp</var>, <emu-val>"flags"</emu-val>).</li><li>Perform ? <emu-xref aoid="RequireObjectCoercible" id="_ref_11401"><a href="abstract-operations.html#sec-requireobjectcoercible">RequireObjectCoercible</a></emu-xref>(<var>flags</var>).</li><li>If ? <emu-xref aoid="ToString" id="_ref_11402"><a href="abstract-operations.html#sec-tostring" class="e-user-code">ToString</a></emu-xref>(<var>flags</var>) does not contain <emu-val>"g"</emu-val>, throw a <emu-val>TypeError</emu-val> exception.</li></ol></li><li>Let <var>matcher</var> be ? <emu-xref aoid="GetMethod" id="_ref_11403"><a href="abstract-operations.html#sec-getmethod" class="e-user-code">GetMethod</a></emu-xref>(<var>regexp</var>, <emu-xref href="#sec-well-known-symbols" id="_ref_11404"><a href="ecmascript-data-types-and-values.html#sec-well-known-symbols">%Symbol.matchAll%</a></emu-xref>).</li><li>If <var>matcher</var> is not <emu-val>undefined</emu-val>, then<ol><li>Return ? <emu-xref aoid="Call" id="_ref_11405"><a href="abstract-operations.html#sec-call" class="e-user-code">Call</a></emu-xref>(<var>matcher</var>, <var>regexp</var>, « <var>O</var> »).</li></ol></li></ol></li><li>Let <var>S</var> be ? <emu-xref aoid="ToString" id="_ref_11406"><a href="abstract-operations.html#sec-tostring" class="e-user-code">ToString</a></emu-xref>(<var>O</var>).</li><li>Let <var>rx</var> be ? <emu-xref aoid="RegExpCreate" id="_ref_11407"><a href="text-processing.html#sec-regexpcreate" class="e-user-code">RegExpCreate</a></emu-xref>(<var>regexp</var>, <emu-val>"g"</emu-val>).</li><li>Return ? <emu-xref aoid="Invoke" id="_ref_11408"><a href="abstract-operations.html#sec-invoke" class="e-user-code">Invoke</a></emu-xref>(<var>rx</var>, <emu-xref href="#sec-well-known-symbols" id="_ref_11409"><a href="ecmascript-data-types-and-values.html#sec-well-known-symbols">%Symbol.matchAll%</a></emu-xref>, « <var>S</var> »).</li></ol></emu-alg>
|
||
<emu-note><span class="note">Note 1</span><div class="note-contents">This method is intentionally generic, it does not require that its <emu-val>this</emu-val> value be a String object. Therefore, it can be transferred to other kinds of objects for use as a method.</div></emu-note>
|
||
<emu-note><span class="note">Note 2</span><div class="note-contents">Similarly to <code>String.prototype.split</code>, <code>String.prototype.matchAll</code> is designed to typically act without mutating its inputs.</div></emu-note>
|
||
</emu-clause>
|
||
|
||
<emu-clause id="sec-string.prototype.normalize" type="built-in function">
|
||
<h1><span class="secnum">22.1.3.15</span> String.prototype.normalize ( [ <var>form</var> ] )</h1>
|
||
<p>This method performs the following steps when called:</p>
|
||
<emu-alg><ol><li>Let <var>O</var> be the <emu-val>this</emu-val> value.</li><li>Perform ? <emu-xref aoid="RequireObjectCoercible" id="_ref_11410"><a href="abstract-operations.html#sec-requireobjectcoercible">RequireObjectCoercible</a></emu-xref>(<var>O</var>).</li><li>Let <var>S</var> be ? <emu-xref aoid="ToString" id="_ref_11411"><a href="abstract-operations.html#sec-tostring" class="e-user-code">ToString</a></emu-xref>(<var>O</var>).</li><li>If <var>form</var> is <emu-val>undefined</emu-val>, let <var>f</var> be <emu-val>"NFC"</emu-val>.</li><li>Else, let <var>f</var> be ? <emu-xref aoid="ToString" id="_ref_11412"><a href="abstract-operations.html#sec-tostring" class="e-user-code">ToString</a></emu-xref>(<var>form</var>).</li><li>If <var>f</var> is not one of <emu-val>"NFC"</emu-val>, <emu-val>"NFD"</emu-val>, <emu-val>"NFKC"</emu-val>, or <emu-val>"NFKD"</emu-val>, throw a <emu-val>RangeError</emu-val> exception.</li><li>Let <var>ns</var> be the String value that is the result of normalizing <var>S</var> into the normalization form named by <var>f</var> as specified in <a href="https://www.unicode.org/versions/latest/ch03.pdf">the latest Unicode Standard, Normalization Forms</a>.</li><li>Return <var>ns</var>.</li></ol></emu-alg>
|
||
<emu-note><span class="note">Note</span><div class="note-contents">
|
||
<p>This method is intentionally generic; it does not require that its <emu-val>this</emu-val> value be a String object. Therefore it can be transferred to other kinds of objects for use as a method.</p>
|
||
</div></emu-note>
|
||
</emu-clause>
|
||
|
||
<emu-clause id="sec-string.prototype.padend" type="built-in function">
|
||
<h1><span class="secnum">22.1.3.16</span> String.prototype.padEnd ( <var>maxLength</var> [ , <var>fillString</var> ] )</h1>
|
||
<p>This method performs the following steps when called:</p>
|
||
<emu-alg><ol><li>Let <var>O</var> be the <emu-val>this</emu-val> value.</li><li>Perform ? <emu-xref aoid="RequireObjectCoercible" id="_ref_11413"><a href="abstract-operations.html#sec-requireobjectcoercible">RequireObjectCoercible</a></emu-xref>(<var>O</var>).</li><li>Return ? <emu-xref aoid="StringPaddingBuiltinsImpl" id="_ref_11414"><a href="text-processing.html#sec-stringpaddingbuiltinsimpl" class="e-user-code">StringPaddingBuiltinsImpl</a></emu-xref>(<var>O</var>, <var>maxLength</var>, <var>fillString</var>, <emu-const>end</emu-const>).</li></ol></emu-alg>
|
||
</emu-clause>
|
||
|
||
<emu-clause id="sec-string.prototype.padstart" type="built-in function">
|
||
<h1><span class="secnum">22.1.3.17</span> String.prototype.padStart ( <var>maxLength</var> [ , <var>fillString</var> ] )</h1>
|
||
<p>This method performs the following steps when called:</p>
|
||
<emu-alg><ol><li>Let <var>O</var> be the <emu-val>this</emu-val> value.</li><li>Perform ? <emu-xref aoid="RequireObjectCoercible" id="_ref_11415"><a href="abstract-operations.html#sec-requireobjectcoercible">RequireObjectCoercible</a></emu-xref>(<var>O</var>).</li><li>Return ? <emu-xref aoid="StringPaddingBuiltinsImpl" id="_ref_11416"><a href="text-processing.html#sec-stringpaddingbuiltinsimpl" class="e-user-code">StringPaddingBuiltinsImpl</a></emu-xref>(<var>O</var>, <var>maxLength</var>, <var>fillString</var>, <emu-const>start</emu-const>).</li></ol></emu-alg>
|
||
|
||
<emu-clause id="sec-stringpaddingbuiltinsimpl" type="abstract operation" aoid="StringPaddingBuiltinsImpl">
|
||
<h1><span class="secnum">22.1.3.17.1</span> StringPaddingBuiltinsImpl ( <var>O</var>, <var>maxLength</var>, <var>fillString</var>, <var>placement</var> )</h1>
|
||
<p>The abstract operation StringPaddingBuiltinsImpl takes arguments <var>O</var> (an <emu-xref href="#sec-ecmascript-language-types" id="_ref_11417"><a href="ecmascript-data-types-and-values.html#sec-ecmascript-language-types">ECMAScript language value</a></emu-xref>), <var>maxLength</var> (an <emu-xref href="#sec-ecmascript-language-types" id="_ref_11418"><a href="ecmascript-data-types-and-values.html#sec-ecmascript-language-types">ECMAScript language value</a></emu-xref>), <var>fillString</var> (an <emu-xref href="#sec-ecmascript-language-types" id="_ref_11419"><a href="ecmascript-data-types-and-values.html#sec-ecmascript-language-types">ECMAScript language value</a></emu-xref>), and <var>placement</var> (<emu-const>start</emu-const> or <emu-const>end</emu-const>) and returns either a <emu-xref href="#sec-completion-record-specification-type" id="_ref_11420"><a href="ecmascript-data-types-and-values.html#sec-completion-record-specification-type">normal completion containing</a></emu-xref> a String or a <emu-xref href="#sec-completion-record-specification-type" id="_ref_11421"><a href="ecmascript-data-types-and-values.html#sec-completion-record-specification-type">throw completion</a></emu-xref>. It performs the following steps when called:</p>
|
||
<emu-alg><ol><li>Let <var>S</var> be ? <emu-xref aoid="ToString" id="_ref_11422"><a href="abstract-operations.html#sec-tostring" class="e-user-code">ToString</a></emu-xref>(<var>O</var>).</li><li>Let <var>intMaxLength</var> be <emu-xref aoid="ℝ" id="_ref_11423"><a href="notational-conventions.html#%E2%84%9D">ℝ</a></emu-xref>(? <emu-xref aoid="ToLength" id="_ref_11424"><a href="abstract-operations.html#sec-tolength" class="e-user-code">ToLength</a></emu-xref>(<var>maxLength</var>)).</li><li>Let <var>stringLength</var> be the length of <var>S</var>.</li><li>If <var>intMaxLength</var> ≤ <var>stringLength</var>, return <var>S</var>.</li><li>If <var>fillString</var> is <emu-val>undefined</emu-val>, set <var>fillString</var> to the String value consisting solely of the code unit 0x0020 (SPACE).</li><li>Else, set <var>fillString</var> to ? <emu-xref aoid="ToString" id="_ref_11425"><a href="abstract-operations.html#sec-tostring" class="e-user-code">ToString</a></emu-xref>(<var>fillString</var>).</li><li>Return <emu-xref aoid="StringPad" id="_ref_11426"><a href="text-processing.html#sec-stringpad">StringPad</a></emu-xref>(<var>S</var>, <var>intMaxLength</var>, <var>fillString</var>, <var>placement</var>).</li></ol></emu-alg>
|
||
</emu-clause>
|
||
|
||
<emu-clause id="sec-stringpad" type="abstract operation" aoid="StringPad">
|
||
<h1><span class="secnum">22.1.3.17.2</span> StringPad ( <var>S</var>, <var>maxLength</var>, <var>fillString</var>, <var>placement</var> )</h1>
|
||
<p>The abstract operation StringPad takes arguments <var>S</var> (a String), <var>maxLength</var> (a non-negative <emu-xref href="#integer" id="_ref_11427"><a href="notational-conventions.html#integer">integer</a></emu-xref>), <var>fillString</var> (a String), and <var>placement</var> (<emu-const>start</emu-const> or <emu-const>end</emu-const>) and returns a String. It performs the following steps when called:</p>
|
||
<emu-alg><ol><li>Let <var>stringLength</var> be the length of <var>S</var>.</li><li>If <var>maxLength</var> ≤ <var>stringLength</var>, return <var>S</var>.</li><li>If <var>fillString</var> is the empty String, return <var>S</var>.</li><li>Let <var>fillLen</var> be <var>maxLength</var> - <var>stringLength</var>.</li><li>Let <var>truncatedStringFiller</var> be the String value consisting of repeated concatenations of <var>fillString</var> truncated to length <var>fillLen</var>.</li><li>If <var>placement</var> is <emu-const>start</emu-const>, return the <emu-xref href="#string-concatenation" id="_ref_11428"><a href="ecmascript-data-types-and-values.html#string-concatenation">string-concatenation</a></emu-xref> of <var>truncatedStringFiller</var> and <var>S</var>.</li><li>Return the <emu-xref href="#string-concatenation" id="_ref_11429"><a href="ecmascript-data-types-and-values.html#string-concatenation">string-concatenation</a></emu-xref> of <var>S</var> and <var>truncatedStringFiller</var>.</li></ol></emu-alg>
|
||
<emu-note><span class="note">Note 1</span><div class="note-contents">
|
||
<p>The argument <var>maxLength</var> will be clamped such that it can be no smaller than the length of <var>S</var>.</p>
|
||
</div></emu-note>
|
||
<emu-note><span class="note">Note 2</span><div class="note-contents">
|
||
<p>The argument <var>fillString</var> defaults to <emu-val>" "</emu-val> (the String value consisting of the code unit 0x0020 SPACE).</p>
|
||
</div></emu-note>
|
||
</emu-clause>
|
||
|
||
<emu-clause id="sec-tozeropaddeddecimalstring" type="abstract operation" aoid="ToZeroPaddedDecimalString">
|
||
<h1><span class="secnum">22.1.3.17.3</span> ToZeroPaddedDecimalString ( <var>n</var>, <var>minLength</var> )</h1>
|
||
<p>The abstract operation ToZeroPaddedDecimalString takes arguments <var>n</var> (a non-negative <emu-xref href="#integer" id="_ref_11430"><a href="notational-conventions.html#integer">integer</a></emu-xref>) and <var>minLength</var> (a non-negative <emu-xref href="#integer" id="_ref_11431"><a href="notational-conventions.html#integer">integer</a></emu-xref>) and returns a String. It performs the following steps when called:</p>
|
||
<emu-alg><ol><li>Let <var>S</var> be the String representation of <var>n</var>, formatted as a decimal number.</li><li>Return <emu-xref aoid="StringPad" id="_ref_11432"><a href="text-processing.html#sec-stringpad">StringPad</a></emu-xref>(<var>S</var>, <var>minLength</var>, <emu-val>"0"</emu-val>, <emu-const>start</emu-const>).</li></ol></emu-alg>
|
||
</emu-clause>
|
||
</emu-clause>
|
||
|
||
<emu-clause id="sec-string.prototype.repeat" type="built-in function">
|
||
<h1><span class="secnum">22.1.3.18</span> String.prototype.repeat ( <var>count</var> )</h1>
|
||
<p>This method performs the following steps when called:</p>
|
||
<emu-alg><ol><li>Let <var>O</var> be the <emu-val>this</emu-val> value.</li><li>Perform ? <emu-xref aoid="RequireObjectCoercible" id="_ref_11433"><a href="abstract-operations.html#sec-requireobjectcoercible">RequireObjectCoercible</a></emu-xref>(<var>O</var>).</li><li>Let <var>S</var> be ? <emu-xref aoid="ToString" id="_ref_11434"><a href="abstract-operations.html#sec-tostring" class="e-user-code">ToString</a></emu-xref>(<var>O</var>).</li><li>Let <var>n</var> be ? <emu-xref aoid="ToIntegerOrInfinity" id="_ref_11435"><a href="abstract-operations.html#sec-tointegerorinfinity" class="e-user-code">ToIntegerOrInfinity</a></emu-xref>(<var>count</var>).</li><li>If <var>n</var> < 0 or <var>n</var> = +∞, throw a <emu-val>RangeError</emu-val> exception.</li><li>If <var>n</var> = 0, return the empty String.</li><li>Return the String value that is made from <var>n</var> copies of <var>S</var> appended together.</li></ol></emu-alg>
|
||
<emu-note><span class="note">Note 1</span><div class="note-contents">
|
||
<p>This method creates the String value consisting of the code units of the <emu-val>this</emu-val> value (converted to String) repeated <var>count</var> times.</p>
|
||
</div></emu-note>
|
||
<emu-note><span class="note">Note 2</span><div class="note-contents">
|
||
<p>This method is intentionally generic; it does not require that its <emu-val>this</emu-val> value be a String object. Therefore, it can be transferred to other kinds of objects for use as a method.</p>
|
||
</div></emu-note>
|
||
</emu-clause>
|
||
|
||
<emu-clause id="sec-string.prototype.replace" type="built-in function">
|
||
<h1><span class="secnum">22.1.3.19</span> String.prototype.replace ( <var>searchValue</var>, <var>replaceValue</var> )</h1>
|
||
<p>This method performs the following steps when called:</p>
|
||
<emu-alg><ol><li>Let <var>O</var> be the <emu-val>this</emu-val> value.</li><li>Perform ? <emu-xref aoid="RequireObjectCoercible" id="_ref_11436"><a href="abstract-operations.html#sec-requireobjectcoercible">RequireObjectCoercible</a></emu-xref>(<var>O</var>).</li><li>If <var>searchValue</var> <emu-xref href="#sec-object-type" id="_ref_11437"><a href="ecmascript-data-types-and-values.html#sec-object-type">is an Object</a></emu-xref>, then<ol><li>Let <var>replacer</var> be ? <emu-xref aoid="GetMethod" id="_ref_11438"><a href="abstract-operations.html#sec-getmethod" class="e-user-code">GetMethod</a></emu-xref>(<var>searchValue</var>, <emu-xref href="#sec-well-known-symbols" id="_ref_11439"><a href="ecmascript-data-types-and-values.html#sec-well-known-symbols">%Symbol.replace%</a></emu-xref>).</li><li>If <var>replacer</var> is not <emu-val>undefined</emu-val>, then<ol><li>Return ? <emu-xref aoid="Call" id="_ref_11440"><a href="abstract-operations.html#sec-call" class="e-user-code">Call</a></emu-xref>(<var>replacer</var>, <var>searchValue</var>, « <var>O</var>, <var>replaceValue</var> »).</li></ol></li></ol></li><li>Let <var>string</var> be ? <emu-xref aoid="ToString" id="_ref_11441"><a href="abstract-operations.html#sec-tostring" class="e-user-code">ToString</a></emu-xref>(<var>O</var>).</li><li>Let <var>searchString</var> be ? <emu-xref aoid="ToString" id="_ref_11442"><a href="abstract-operations.html#sec-tostring" class="e-user-code">ToString</a></emu-xref>(<var>searchValue</var>).</li><li>Let <var>functionalReplace</var> be <emu-xref aoid="IsCallable" id="_ref_11443"><a href="abstract-operations.html#sec-iscallable">IsCallable</a></emu-xref>(<var>replaceValue</var>).</li><li>If <var>functionalReplace</var> is <emu-val>false</emu-val>, then<ol><li>Set <var>replaceValue</var> to ? <emu-xref aoid="ToString" id="_ref_11444"><a href="abstract-operations.html#sec-tostring" class="e-user-code">ToString</a></emu-xref>(<var>replaceValue</var>).</li></ol></li><li>Let <var>searchLength</var> be the length of <var>searchString</var>.</li><li>Let <var>position</var> be <emu-xref aoid="StringIndexOf" id="_ref_11445"><a href="ecmascript-data-types-and-values.html#sec-stringindexof">StringIndexOf</a></emu-xref>(<var>string</var>, <var>searchString</var>, 0).</li><li>If <var>position</var> is <emu-const>not-found</emu-const>, return <var>string</var>.</li><li>Let <var>preceding</var> be the <emu-xref href="#substring" id="_ref_11446"><a href="ecmascript-data-types-and-values.html#substring">substring</a></emu-xref> of <var>string</var> from 0 to <var>position</var>.</li><li>Let <var>following</var> be the <emu-xref href="#substring" id="_ref_11447"><a href="ecmascript-data-types-and-values.html#substring">substring</a></emu-xref> of <var>string</var> from <var>position</var> + <var>searchLength</var>.</li><li>If <var>functionalReplace</var> is <emu-val>true</emu-val>, then<ol><li>Let <var>replacement</var> be ? <emu-xref aoid="ToString" id="_ref_11448"><a href="abstract-operations.html#sec-tostring" class="e-user-code">ToString</a></emu-xref>(? <emu-xref aoid="Call" id="_ref_11449"><a href="abstract-operations.html#sec-call" class="e-user-code">Call</a></emu-xref>(<var>replaceValue</var>, <emu-val>undefined</emu-val>, « <var>searchString</var>, <emu-xref aoid="𝔽" id="_ref_11450"><a href="notational-conventions.html#%F0%9D%94%BD">𝔽</a></emu-xref>(<var>position</var>), <var>string</var> »)).</li></ol></li><li>Else,<ol><li><emu-xref href="#assert" id="_ref_11451"><a href="notational-conventions.html#assert">Assert</a></emu-xref>: <var>replaceValue</var> <emu-xref href="#sec-ecmascript-language-types-string-type" id="_ref_11452"><a href="ecmascript-data-types-and-values.html#sec-ecmascript-language-types-string-type">is a String</a></emu-xref>.</li><li>Let <var>captures</var> be a new empty <emu-xref href="#sec-list-and-record-specification-type" id="_ref_11453"><a href="ecmascript-data-types-and-values.html#sec-list-and-record-specification-type">List</a></emu-xref>.</li><li>Let <var>replacement</var> be ! <emu-xref aoid="GetSubstitution" id="_ref_11454"><a href="text-processing.html#sec-getsubstitution">GetSubstitution</a></emu-xref>(<var>searchString</var>, <var>string</var>, <var>position</var>, <var>captures</var>, <emu-val>undefined</emu-val>, <var>replaceValue</var>).</li></ol></li><li>Return the <emu-xref href="#string-concatenation" id="_ref_11455"><a href="ecmascript-data-types-and-values.html#string-concatenation">string-concatenation</a></emu-xref> of <var>preceding</var>, <var>replacement</var>, and <var>following</var>.</li></ol></emu-alg>
|
||
<emu-note><span class="note">Note</span><div class="note-contents">
|
||
<p>This method is intentionally generic; it does not require that its <emu-val>this</emu-val> value be a String object. Therefore, it can be transferred to other kinds of objects for use as a method.</p>
|
||
</div></emu-note>
|
||
|
||
<emu-clause id="sec-getsubstitution" type="abstract operation" oldids="table-replacement-text-symbol-substitutions,table-45" aoid="GetSubstitution"><span id="table-45"></span><span id="table-replacement-text-symbol-substitutions"></span>
|
||
<h1><span class="secnum">22.1.3.19.1</span> GetSubstitution ( <var>matched</var>, <var>str</var>, <var>position</var>, <var>captures</var>, <var>namedCaptures</var>, <var>replacementTemplate</var> )</h1>
|
||
<p>The abstract operation GetSubstitution takes arguments <var>matched</var> (a String), <var>str</var> (a String), <var>position</var> (a non-negative <emu-xref href="#integer" id="_ref_11456"><a href="notational-conventions.html#integer">integer</a></emu-xref>), <var>captures</var> (a <emu-xref href="#sec-list-and-record-specification-type" id="_ref_11457"><a href="ecmascript-data-types-and-values.html#sec-list-and-record-specification-type">List</a></emu-xref> of either Strings or <emu-val>undefined</emu-val>), <var>namedCaptures</var> (an Object or <emu-val>undefined</emu-val>), and <var>replacementTemplate</var> (a String) and returns either a <emu-xref href="#sec-completion-record-specification-type" id="_ref_11458"><a href="ecmascript-data-types-and-values.html#sec-completion-record-specification-type">normal completion containing</a></emu-xref> a String or a <emu-xref href="#sec-completion-record-specification-type" id="_ref_11459"><a href="ecmascript-data-types-and-values.html#sec-completion-record-specification-type">throw completion</a></emu-xref>. For the purposes of this abstract operation, a <em>decimal digit</em> is a code unit in the <emu-xref href="#inclusive-interval" id="_ref_11460"><a href="notational-conventions.html#inclusive-interval">inclusive interval</a></emu-xref> from 0x0030 (DIGIT ZERO) to 0x0039 (DIGIT NINE). It performs the following steps when called:</p>
|
||
<emu-alg><ol><li>Let <var>stringLength</var> be the length of <var>str</var>.</li><li><emu-xref href="#assert" id="_ref_11461"><a href="notational-conventions.html#assert">Assert</a></emu-xref>: <var>position</var> ≤ <var>stringLength</var>.</li><li>Let <var>result</var> be the empty String.</li><li>Let <var>templateRemainder</var> be <var>replacementTemplate</var>.</li><li>Repeat, while <var>templateRemainder</var> is not the empty String,<ol><li declared="ref,refReplacement">NOTE: The following steps isolate <var>ref</var> (a prefix of <var>templateRemainder</var>), determine <var>refReplacement</var> (its replacement), and then append that replacement to <var>result</var>.</li><li>If <var>templateRemainder</var> starts with <emu-val>"$$"</emu-val>, then<ol><li>Let <var>ref</var> be <emu-val>"$$"</emu-val>.</li><li>Let <var>refReplacement</var> be <emu-val>"$"</emu-val>.</li></ol></li><li>Else if <var>templateRemainder</var> starts with <emu-val>"$`"</emu-val>, then<ol><li>Let <var>ref</var> be <emu-val>"$`"</emu-val>.</li><li>Let <var>refReplacement</var> be the <emu-xref href="#substring" id="_ref_11462"><a href="ecmascript-data-types-and-values.html#substring">substring</a></emu-xref> of <var>str</var> from 0 to <var>position</var>.</li></ol></li><li>Else if <var>templateRemainder</var> starts with <emu-val>"$&"</emu-val>, then<ol><li>Let <var>ref</var> be <emu-val>"$&"</emu-val>.</li><li>Let <var>refReplacement</var> be <var>matched</var>.</li></ol></li><li>Else if <var>templateRemainder</var> starts with <emu-val>"$'"</emu-val> (0x0024 (DOLLAR SIGN) followed by 0x0027 (APOSTROPHE)), then<ol><li>Let <var>ref</var> be <emu-val>"$'"</emu-val>.</li><li>Let <var>matchLength</var> be the length of <var>matched</var>.</li><li>Let <var>tailPos</var> be <var>position</var> + <var>matchLength</var>.</li><li>Let <var>refReplacement</var> be the <emu-xref href="#substring" id="_ref_11463"><a href="ecmascript-data-types-and-values.html#substring">substring</a></emu-xref> of <var>str</var> from <emu-xref aoid="min" id="_ref_11464"><a href="notational-conventions.html#eqn-min">min</a></emu-xref>(<var>tailPos</var>, <var>stringLength</var>).</li><li>NOTE: <var>tailPos</var> can exceed <var>stringLength</var> only if this abstract operation was invoked by a call to the intrinsic <emu-xref href="#sec-well-known-symbols" id="_ref_11465"><a href="ecmascript-data-types-and-values.html#sec-well-known-symbols">%Symbol.replace%</a></emu-xref> method of <emu-xref href="#sec-properties-of-the-regexp-prototype-object" id="_ref_11466"><a href="text-processing.html#sec-properties-of-the-regexp-prototype-object">%RegExp.prototype%</a></emu-xref> on an object whose <emu-val>"exec"</emu-val> property is not the intrinsic %RegExp.prototype.exec%.</li></ol></li><li>Else if <var>templateRemainder</var> starts with <emu-val>"$"</emu-val> followed by 1 or more decimal digits, then<ol><li>If <var>templateRemainder</var> starts with <emu-val>"$"</emu-val> followed by 2 or more decimal digits, let <var>digitCount</var> be 2; else let <var>digitCount</var> be 1.</li><li>Let <var>digits</var> be the <emu-xref href="#substring" id="_ref_11467"><a href="ecmascript-data-types-and-values.html#substring">substring</a></emu-xref> of <var>templateRemainder</var> from 1 to 1 + <var>digitCount</var>.</li><li>Let <var>index</var> be <emu-xref aoid="ℝ" id="_ref_11468"><a href="notational-conventions.html#%E2%84%9D">ℝ</a></emu-xref>(<emu-xref aoid="StringToNumber" id="_ref_11469"><a href="abstract-operations.html#sec-stringtonumber">StringToNumber</a></emu-xref>(<var>digits</var>)).</li><li><emu-xref href="#assert" id="_ref_11470"><a href="notational-conventions.html#assert">Assert</a></emu-xref>: 0 ≤ <var>index</var> ≤ 99.</li><li>Let <var>captureLen</var> be the number of elements in <var>captures</var>.</li><li>If <var>index</var> > <var>captureLen</var> and <var>digitCount</var> = 2, then<ol><li>NOTE: When a two-digit replacement pattern specifies an index exceeding the count of capturing groups, it is treated as a one-digit replacement pattern followed by a literal digit.</li><li>Set <var>digitCount</var> to 1.</li><li>Set <var>digits</var> to the <emu-xref href="#substring" id="_ref_11471"><a href="ecmascript-data-types-and-values.html#substring">substring</a></emu-xref> of <var>digits</var> from 0 to 1.</li><li>Set <var>index</var> to <emu-xref aoid="ℝ" id="_ref_11472"><a href="notational-conventions.html#%E2%84%9D">ℝ</a></emu-xref>(<emu-xref aoid="StringToNumber" id="_ref_11473"><a href="abstract-operations.html#sec-stringtonumber">StringToNumber</a></emu-xref>(<var>digits</var>)).</li></ol></li><li>Let <var>ref</var> be the <emu-xref href="#substring" id="_ref_11474"><a href="ecmascript-data-types-and-values.html#substring">substring</a></emu-xref> of <var>templateRemainder</var> from 0 to 1 + <var>digitCount</var>.</li><li>If 1 ≤ <var>index</var> ≤ <var>captureLen</var>, then<ol><li>Let <var>capture</var> be <var>captures</var>[<var>index</var> - 1].</li><li>If <var>capture</var> is <emu-val>undefined</emu-val>, then<ol><li>Let <var>refReplacement</var> be the empty String.</li></ol></li><li>Else,<ol><li>Let <var>refReplacement</var> be <var>capture</var>.</li></ol></li></ol></li><li>Else,<ol><li>Let <var>refReplacement</var> be <var>ref</var>.</li></ol></li></ol></li><li>Else if <var>templateRemainder</var> starts with <emu-val>"$<"</emu-val>, then<ol><li>Let <var>gtPos</var> be <emu-xref aoid="StringIndexOf" id="_ref_11475"><a href="ecmascript-data-types-and-values.html#sec-stringindexof">StringIndexOf</a></emu-xref>(<var>templateRemainder</var>, <emu-val>">"</emu-val>, 0).</li><li>If <var>gtPos</var> is <emu-const>not-found</emu-const> or <var>namedCaptures</var> is <emu-val>undefined</emu-val>, then<ol><li>Let <var>ref</var> be <emu-val>"$<"</emu-val>.</li><li>Let <var>refReplacement</var> be <var>ref</var>.</li></ol></li><li>Else,<ol><li>Let <var>ref</var> be the <emu-xref href="#substring" id="_ref_11476"><a href="ecmascript-data-types-and-values.html#substring">substring</a></emu-xref> of <var>templateRemainder</var> from 0 to <var>gtPos</var> + 1.</li><li>Let <var>groupName</var> be the <emu-xref href="#substring" id="_ref_11477"><a href="ecmascript-data-types-and-values.html#substring">substring</a></emu-xref> of <var>templateRemainder</var> from 2 to <var>gtPos</var>.</li><li><emu-xref href="#assert" id="_ref_11478"><a href="notational-conventions.html#assert">Assert</a></emu-xref>: <var>namedCaptures</var> <emu-xref href="#sec-object-type" id="_ref_11479"><a href="ecmascript-data-types-and-values.html#sec-object-type">is an Object</a></emu-xref>.</li><li>Let <var>capture</var> be ? <emu-xref aoid="Get" id="_ref_11480"><a href="abstract-operations.html#sec-get-o-p" class="e-user-code">Get</a></emu-xref>(<var>namedCaptures</var>, <var>groupName</var>).</li><li>If <var>capture</var> is <emu-val>undefined</emu-val>, then<ol><li>Let <var>refReplacement</var> be the empty String.</li></ol></li><li>Else,<ol><li>Let <var>refReplacement</var> be ? <emu-xref aoid="ToString" id="_ref_11481"><a href="abstract-operations.html#sec-tostring" class="e-user-code">ToString</a></emu-xref>(<var>capture</var>).</li></ol></li></ol></li></ol></li><li>Else,<ol><li>Let <var>ref</var> be the <emu-xref href="#substring" id="_ref_11482"><a href="ecmascript-data-types-and-values.html#substring">substring</a></emu-xref> of <var>templateRemainder</var> from 0 to 1.</li><li>Let <var>refReplacement</var> be <var>ref</var>.</li></ol></li><li>Let <var>refLength</var> be the length of <var>ref</var>.</li><li>Set <var>templateRemainder</var> to the <emu-xref href="#substring" id="_ref_11483"><a href="ecmascript-data-types-and-values.html#substring">substring</a></emu-xref> of <var>templateRemainder</var> from <var>refLength</var>.</li><li>Set <var>result</var> to the <emu-xref href="#string-concatenation" id="_ref_11484"><a href="ecmascript-data-types-and-values.html#string-concatenation">string-concatenation</a></emu-xref> of <var>result</var> and <var>refReplacement</var>.</li></ol></li><li>Return <var>result</var>.</li></ol></emu-alg>
|
||
</emu-clause>
|
||
</emu-clause>
|
||
|
||
<emu-clause id="sec-string.prototype.replaceall" type="built-in function">
|
||
<h1><span class="secnum">22.1.3.20</span> String.prototype.replaceAll ( <var>searchValue</var>, <var>replaceValue</var> )</h1>
|
||
<p>This method performs the following steps when called:</p>
|
||
<emu-alg><ol><li>Let <var>O</var> be the <emu-val>this</emu-val> value.</li><li>Perform ? <emu-xref aoid="RequireObjectCoercible" id="_ref_11485"><a href="abstract-operations.html#sec-requireobjectcoercible">RequireObjectCoercible</a></emu-xref>(<var>O</var>).</li><li>If <var>searchValue</var> <emu-xref href="#sec-object-type" id="_ref_11486"><a href="ecmascript-data-types-and-values.html#sec-object-type">is an Object</a></emu-xref>, then<ol><li>Let <var>isRegExp</var> be ? <emu-xref aoid="IsRegExp" id="_ref_11487"><a href="abstract-operations.html#sec-isregexp" class="e-user-code">IsRegExp</a></emu-xref>(<var>searchValue</var>).</li><li>If <var>isRegExp</var> is <emu-val>true</emu-val>, then<ol><li>Let <var>flags</var> be ? <emu-xref aoid="Get" id="_ref_11488"><a href="abstract-operations.html#sec-get-o-p" class="e-user-code">Get</a></emu-xref>(<var>searchValue</var>, <emu-val>"flags"</emu-val>).</li><li>Perform ? <emu-xref aoid="RequireObjectCoercible" id="_ref_11489"><a href="abstract-operations.html#sec-requireobjectcoercible">RequireObjectCoercible</a></emu-xref>(<var>flags</var>).</li><li>If ? <emu-xref aoid="ToString" id="_ref_11490"><a href="abstract-operations.html#sec-tostring" class="e-user-code">ToString</a></emu-xref>(<var>flags</var>) does not contain <emu-val>"g"</emu-val>, throw a <emu-val>TypeError</emu-val> exception.</li></ol></li><li>Let <var>replacer</var> be ? <emu-xref aoid="GetMethod" id="_ref_11491"><a href="abstract-operations.html#sec-getmethod" class="e-user-code">GetMethod</a></emu-xref>(<var>searchValue</var>, <emu-xref href="#sec-well-known-symbols" id="_ref_11492"><a href="ecmascript-data-types-and-values.html#sec-well-known-symbols">%Symbol.replace%</a></emu-xref>).</li><li>If <var>replacer</var> is not <emu-val>undefined</emu-val>, then<ol><li>Return ? <emu-xref aoid="Call" id="_ref_11493"><a href="abstract-operations.html#sec-call" class="e-user-code">Call</a></emu-xref>(<var>replacer</var>, <var>searchValue</var>, « <var>O</var>, <var>replaceValue</var> »).</li></ol></li></ol></li><li>Let <var>string</var> be ? <emu-xref aoid="ToString" id="_ref_11494"><a href="abstract-operations.html#sec-tostring" class="e-user-code">ToString</a></emu-xref>(<var>O</var>).</li><li>Let <var>searchString</var> be ? <emu-xref aoid="ToString" id="_ref_11495"><a href="abstract-operations.html#sec-tostring" class="e-user-code">ToString</a></emu-xref>(<var>searchValue</var>).</li><li>Let <var>functionalReplace</var> be <emu-xref aoid="IsCallable" id="_ref_11496"><a href="abstract-operations.html#sec-iscallable">IsCallable</a></emu-xref>(<var>replaceValue</var>).</li><li>If <var>functionalReplace</var> is <emu-val>false</emu-val>, then<ol><li>Set <var>replaceValue</var> to ? <emu-xref aoid="ToString" id="_ref_11497"><a href="abstract-operations.html#sec-tostring" class="e-user-code">ToString</a></emu-xref>(<var>replaceValue</var>).</li></ol></li><li>Let <var>searchLength</var> be the length of <var>searchString</var>.</li><li>Let <var>advanceBy</var> be <emu-xref aoid="max" id="_ref_11498"><a href="notational-conventions.html#eqn-max">max</a></emu-xref>(1, <var>searchLength</var>).</li><li>Let <var>matchPositions</var> be a new empty <emu-xref href="#sec-list-and-record-specification-type" id="_ref_11499"><a href="ecmascript-data-types-and-values.html#sec-list-and-record-specification-type">List</a></emu-xref>.</li><li>Let <var>position</var> be <emu-xref aoid="StringIndexOf" id="_ref_11500"><a href="ecmascript-data-types-and-values.html#sec-stringindexof">StringIndexOf</a></emu-xref>(<var>string</var>, <var>searchString</var>, 0).</li><li>Repeat, while <var>position</var> is not <emu-const>not-found</emu-const>,<ol><li>Append <var>position</var> to <var>matchPositions</var>.</li><li>Set <var>position</var> to <emu-xref aoid="StringIndexOf" id="_ref_11501"><a href="ecmascript-data-types-and-values.html#sec-stringindexof">StringIndexOf</a></emu-xref>(<var>string</var>, <var>searchString</var>, <var>position</var> + <var>advanceBy</var>).</li></ol></li><li>Let <var>endOfLastMatch</var> be 0.</li><li>Let <var>result</var> be the empty String.</li><li>For each element <var>p</var> of <var>matchPositions</var>, do<ol><li>Let <var>preserved</var> be the <emu-xref href="#substring" id="_ref_11502"><a href="ecmascript-data-types-and-values.html#substring">substring</a></emu-xref> of <var>string</var> from <var>endOfLastMatch</var> to <var>p</var>.</li><li>If <var>functionalReplace</var> is <emu-val>true</emu-val>, then<ol><li>Let <var>replacement</var> be ? <emu-xref aoid="ToString" id="_ref_11503"><a href="abstract-operations.html#sec-tostring" class="e-user-code">ToString</a></emu-xref>(? <emu-xref aoid="Call" id="_ref_11504"><a href="abstract-operations.html#sec-call" class="e-user-code">Call</a></emu-xref>(<var>replaceValue</var>, <emu-val>undefined</emu-val>, « <var>searchString</var>, <emu-xref aoid="𝔽" id="_ref_11505"><a href="notational-conventions.html#%F0%9D%94%BD">𝔽</a></emu-xref>(<var>p</var>), <var>string</var> »)).</li></ol></li><li>Else,<ol><li><emu-xref href="#assert" id="_ref_11506"><a href="notational-conventions.html#assert">Assert</a></emu-xref>: <var>replaceValue</var> <emu-xref href="#sec-ecmascript-language-types-string-type" id="_ref_11507"><a href="ecmascript-data-types-and-values.html#sec-ecmascript-language-types-string-type">is a String</a></emu-xref>.</li><li>Let <var>captures</var> be a new empty <emu-xref href="#sec-list-and-record-specification-type" id="_ref_11508"><a href="ecmascript-data-types-and-values.html#sec-list-and-record-specification-type">List</a></emu-xref>.</li><li>Let <var>replacement</var> be ! <emu-xref aoid="GetSubstitution" id="_ref_11509"><a href="text-processing.html#sec-getsubstitution">GetSubstitution</a></emu-xref>(<var>searchString</var>, <var>string</var>, <var>p</var>, <var>captures</var>, <emu-val>undefined</emu-val>, <var>replaceValue</var>).</li></ol></li><li>Set <var>result</var> to the <emu-xref href="#string-concatenation" id="_ref_11510"><a href="ecmascript-data-types-and-values.html#string-concatenation">string-concatenation</a></emu-xref> of <var>result</var>, <var>preserved</var>, and <var>replacement</var>.</li><li>Set <var>endOfLastMatch</var> to <var>p</var> + <var>searchLength</var>.</li></ol></li><li>If <var>endOfLastMatch</var> < the length of <var>string</var>, then<ol><li>Set <var>result</var> to the <emu-xref href="#string-concatenation" id="_ref_11511"><a href="ecmascript-data-types-and-values.html#string-concatenation">string-concatenation</a></emu-xref> of <var>result</var> and the <emu-xref href="#substring" id="_ref_11512"><a href="ecmascript-data-types-and-values.html#substring">substring</a></emu-xref> of <var>string</var> from <var>endOfLastMatch</var>.</li></ol></li><li>Return <var>result</var>.</li></ol></emu-alg>
|
||
</emu-clause>
|
||
|
||
<emu-clause id="sec-string.prototype.search" type="built-in function">
|
||
<h1><span class="secnum">22.1.3.21</span> String.prototype.search ( <var>regexp</var> )</h1>
|
||
<p>This method performs the following steps when called:</p>
|
||
<emu-alg><ol><li>Let <var>O</var> be the <emu-val>this</emu-val> value.</li><li>Perform ? <emu-xref aoid="RequireObjectCoercible" id="_ref_11513"><a href="abstract-operations.html#sec-requireobjectcoercible">RequireObjectCoercible</a></emu-xref>(<var>O</var>).</li><li>If <var>regexp</var> <emu-xref href="#sec-object-type" id="_ref_11514"><a href="ecmascript-data-types-and-values.html#sec-object-type">is an Object</a></emu-xref>, then<ol><li>Let <var>searcher</var> be ? <emu-xref aoid="GetMethod" id="_ref_11515"><a href="abstract-operations.html#sec-getmethod" class="e-user-code">GetMethod</a></emu-xref>(<var>regexp</var>, <emu-xref href="#sec-well-known-symbols" id="_ref_11516"><a href="ecmascript-data-types-and-values.html#sec-well-known-symbols">%Symbol.search%</a></emu-xref>).</li><li>If <var>searcher</var> is not <emu-val>undefined</emu-val>, then<ol><li>Return ? <emu-xref aoid="Call" id="_ref_11517"><a href="abstract-operations.html#sec-call" class="e-user-code">Call</a></emu-xref>(<var>searcher</var>, <var>regexp</var>, « <var>O</var> »).</li></ol></li></ol></li><li>Let <var>string</var> be ? <emu-xref aoid="ToString" id="_ref_11518"><a href="abstract-operations.html#sec-tostring" class="e-user-code">ToString</a></emu-xref>(<var>O</var>).</li><li>Let <var>rx</var> be ? <emu-xref aoid="RegExpCreate" id="_ref_11519"><a href="text-processing.html#sec-regexpcreate" class="e-user-code">RegExpCreate</a></emu-xref>(<var>regexp</var>, <emu-val>undefined</emu-val>).</li><li>Return ? <emu-xref aoid="Invoke" id="_ref_11520"><a href="abstract-operations.html#sec-invoke" class="e-user-code">Invoke</a></emu-xref>(<var>rx</var>, <emu-xref href="#sec-well-known-symbols" id="_ref_11521"><a href="ecmascript-data-types-and-values.html#sec-well-known-symbols">%Symbol.search%</a></emu-xref>, « <var>string</var> »).</li></ol></emu-alg>
|
||
<emu-note><span class="note">Note</span><div class="note-contents">
|
||
<p>This method is intentionally generic; it does not require that its <emu-val>this</emu-val> value be a String object. Therefore, it can be transferred to other kinds of objects for use as a method.</p>
|
||
</div></emu-note>
|
||
</emu-clause>
|
||
|
||
<emu-clause id="sec-string.prototype.slice" type="built-in function">
|
||
<h1><span class="secnum">22.1.3.22</span> String.prototype.slice ( <var>start</var>, <var>end</var> )</h1>
|
||
<p>This method returns a <emu-not-ref>substring</emu-not-ref> of the result of converting this object to a String, starting from index <var>start</var> and running to, but not including, index <var>end</var> (or through the end of the String if <var>end</var> is <emu-val>undefined</emu-val>). If <var>start</var> is negative, it is treated as <emu-eqn class="inline"><var>sourceLength</var> + <var>start</var></emu-eqn> where <var>sourceLength</var> is the length of the String. If <var>end</var> is negative, it is treated as <emu-eqn class="inline"><var>sourceLength</var> + <var>end</var></emu-eqn> where <var>sourceLength</var> is the length of the String. The result <emu-xref href="#sec-ecmascript-language-types-string-type" id="_ref_11522"><a href="ecmascript-data-types-and-values.html#sec-ecmascript-language-types-string-type">is a String</a></emu-xref> value, not a String object.</p>
|
||
<p>It performs the following steps when called:</p>
|
||
<emu-alg><ol><li>Let <var>O</var> be the <emu-val>this</emu-val> value.</li><li>Perform ? <emu-xref aoid="RequireObjectCoercible" id="_ref_11523"><a href="abstract-operations.html#sec-requireobjectcoercible">RequireObjectCoercible</a></emu-xref>(<var>O</var>).</li><li>Let <var>S</var> be ? <emu-xref aoid="ToString" id="_ref_11524"><a href="abstract-operations.html#sec-tostring" class="e-user-code">ToString</a></emu-xref>(<var>O</var>).</li><li>Let <var>len</var> be the length of <var>S</var>.</li><li>Let <var>intStart</var> be ? <emu-xref aoid="ToIntegerOrInfinity" id="_ref_11525"><a href="abstract-operations.html#sec-tointegerorinfinity" class="e-user-code">ToIntegerOrInfinity</a></emu-xref>(<var>start</var>).</li><li>If <var>intStart</var> = -∞, let <var>from</var> be 0.</li><li>Else if <var>intStart</var> < 0, let <var>from</var> be <emu-xref aoid="max" id="_ref_11526"><a href="notational-conventions.html#eqn-max">max</a></emu-xref>(<var>len</var> + <var>intStart</var>, 0).</li><li>Else, let <var>from</var> be <emu-xref aoid="min" id="_ref_11527"><a href="notational-conventions.html#eqn-min">min</a></emu-xref>(<var>intStart</var>, <var>len</var>).</li><li>If <var>end</var> is <emu-val>undefined</emu-val>, let <var>intEnd</var> be <var>len</var>; else let <var>intEnd</var> be ? <emu-xref aoid="ToIntegerOrInfinity" id="_ref_11528"><a href="abstract-operations.html#sec-tointegerorinfinity" class="e-user-code">ToIntegerOrInfinity</a></emu-xref>(<var>end</var>).</li><li>If <var>intEnd</var> = -∞, let <var>to</var> be 0.</li><li>Else if <var>intEnd</var> < 0, let <var>to</var> be <emu-xref aoid="max" id="_ref_11529"><a href="notational-conventions.html#eqn-max">max</a></emu-xref>(<var>len</var> + <var>intEnd</var>, 0).</li><li>Else, let <var>to</var> be <emu-xref aoid="min" id="_ref_11530"><a href="notational-conventions.html#eqn-min">min</a></emu-xref>(<var>intEnd</var>, <var>len</var>).</li><li>If <var>from</var> ≥ <var>to</var>, return the empty String.</li><li>Return the <emu-xref href="#substring" id="_ref_11531"><a href="ecmascript-data-types-and-values.html#substring">substring</a></emu-xref> of <var>S</var> from <var>from</var> to <var>to</var>.</li></ol></emu-alg>
|
||
<emu-note><span class="note">Note</span><div class="note-contents">
|
||
<p>This method is intentionally generic; it does not require that its <emu-val>this</emu-val> value be a String object. Therefore it can be transferred to other kinds of objects for use as a method.</p>
|
||
</div></emu-note>
|
||
</emu-clause>
|
||
|
||
<emu-clause id="sec-string.prototype.split" type="built-in function">
|
||
<h1><span class="secnum">22.1.3.23</span> String.prototype.split ( <var>separator</var>, <var>limit</var> )</h1>
|
||
<p>This method returns an Array into which substrings of the result of converting this object to a String have been stored. The substrings are determined by searching from left to right for occurrences of <var>separator</var>; these occurrences are not part of any String in the returned array, but serve to divide up the String value. The value of <var>separator</var> may be a String of any length or it may be an object, such as a RegExp, that has a <emu-xref href="#sec-well-known-symbols" id="_ref_11532"><a href="ecmascript-data-types-and-values.html#sec-well-known-symbols">%Symbol.split%</a></emu-xref> method.</p>
|
||
<p>It performs the following steps when called:</p>
|
||
<emu-alg><ol><li>Let <var>O</var> be the <emu-val>this</emu-val> value.</li><li>Perform ? <emu-xref aoid="RequireObjectCoercible" id="_ref_11533"><a href="abstract-operations.html#sec-requireobjectcoercible">RequireObjectCoercible</a></emu-xref>(<var>O</var>).</li><li>If <var>separator</var> <emu-xref href="#sec-object-type" id="_ref_11534"><a href="ecmascript-data-types-and-values.html#sec-object-type">is an Object</a></emu-xref>, then<ol><li>Let <var>splitter</var> be ? <emu-xref aoid="GetMethod" id="_ref_11535"><a href="abstract-operations.html#sec-getmethod" class="e-user-code">GetMethod</a></emu-xref>(<var>separator</var>, <emu-xref href="#sec-well-known-symbols" id="_ref_11536"><a href="ecmascript-data-types-and-values.html#sec-well-known-symbols">%Symbol.split%</a></emu-xref>).</li><li>If <var>splitter</var> is not <emu-val>undefined</emu-val>, then<ol><li>Return ? <emu-xref aoid="Call" id="_ref_11537"><a href="abstract-operations.html#sec-call" class="e-user-code">Call</a></emu-xref>(<var>splitter</var>, <var>separator</var>, « <var>O</var>, <var>limit</var> »).</li></ol></li></ol></li><li>Let <var>S</var> be ? <emu-xref aoid="ToString" id="_ref_11538"><a href="abstract-operations.html#sec-tostring" class="e-user-code">ToString</a></emu-xref>(<var>O</var>).</li><li>If <var>limit</var> is <emu-val>undefined</emu-val>, let <var>lim</var> be 2<sup>32</sup> - 1; else let <var>lim</var> be <emu-xref aoid="ℝ" id="_ref_11539"><a href="notational-conventions.html#%E2%84%9D">ℝ</a></emu-xref>(? <emu-xref aoid="ToUint32" id="_ref_11540"><a href="abstract-operations.html#sec-touint32" class="e-user-code">ToUint32</a></emu-xref>(<var>limit</var>)).</li><li>Let <var>R</var> be ? <emu-xref aoid="ToString" id="_ref_11541"><a href="abstract-operations.html#sec-tostring" class="e-user-code">ToString</a></emu-xref>(<var>separator</var>).</li><li>If <var>lim</var> = 0, then<ol><li>Return <emu-xref aoid="CreateArrayFromList" id="_ref_11542"><a href="abstract-operations.html#sec-createarrayfromlist">CreateArrayFromList</a></emu-xref>(« »).</li></ol></li><li>If <var>separator</var> is <emu-val>undefined</emu-val>, then<ol><li>Return <emu-xref aoid="CreateArrayFromList" id="_ref_11543"><a href="abstract-operations.html#sec-createarrayfromlist">CreateArrayFromList</a></emu-xref>(« <var>S</var> »).</li></ol></li><li>Let <var>separatorLength</var> be the length of <var>R</var>.</li><li>If <var>separatorLength</var> = 0, then<ol><li>Let <var>strLen</var> be the length of <var>S</var>.</li><li>Let <var>outLen</var> be the result of <emu-xref href="#clamping" id="_ref_11544"><a href="notational-conventions.html#clamping">clamping</a></emu-xref> <var>lim</var> between 0 and <var>strLen</var>.</li><li>Let <var>head</var> be the <emu-xref href="#substring" id="_ref_11545"><a href="ecmascript-data-types-and-values.html#substring">substring</a></emu-xref> of <var>S</var> from 0 to <var>outLen</var>.</li><li>Let <var>codeUnits</var> be a <emu-xref href="#sec-list-and-record-specification-type" id="_ref_11546"><a href="ecmascript-data-types-and-values.html#sec-list-and-record-specification-type">List</a></emu-xref> consisting of the sequence of code units that are the elements of <var>head</var>.</li><li>Return <emu-xref aoid="CreateArrayFromList" id="_ref_11547"><a href="abstract-operations.html#sec-createarrayfromlist">CreateArrayFromList</a></emu-xref>(<var>codeUnits</var>).</li></ol></li><li>If <var>S</var> is the empty String, return <emu-xref aoid="CreateArrayFromList" id="_ref_11548"><a href="abstract-operations.html#sec-createarrayfromlist">CreateArrayFromList</a></emu-xref>(« <var>S</var> »).</li><li>Let <var>substrings</var> be a new empty <emu-xref href="#sec-list-and-record-specification-type" id="_ref_11549"><a href="ecmascript-data-types-and-values.html#sec-list-and-record-specification-type">List</a></emu-xref>.</li><li>Let <var>i</var> be 0.</li><li>Let <var>j</var> be <emu-xref aoid="StringIndexOf" id="_ref_11550"><a href="ecmascript-data-types-and-values.html#sec-stringindexof">StringIndexOf</a></emu-xref>(<var>S</var>, <var>R</var>, 0).</li><li>Repeat, while <var>j</var> is not <emu-const>not-found</emu-const>,<ol><li>Let <var>T</var> be the <emu-xref href="#substring" id="_ref_11551"><a href="ecmascript-data-types-and-values.html#substring">substring</a></emu-xref> of <var>S</var> from <var>i</var> to <var>j</var>.</li><li>Append <var>T</var> to <var>substrings</var>.</li><li>If the number of elements in <var>substrings</var> is <var>lim</var>, return <emu-xref aoid="CreateArrayFromList" id="_ref_11552"><a href="abstract-operations.html#sec-createarrayfromlist">CreateArrayFromList</a></emu-xref>(<var>substrings</var>).</li><li>Set <var>i</var> to <var>j</var> + <var>separatorLength</var>.</li><li>Set <var>j</var> to <emu-xref aoid="StringIndexOf" id="_ref_11553"><a href="ecmascript-data-types-and-values.html#sec-stringindexof">StringIndexOf</a></emu-xref>(<var>S</var>, <var>R</var>, <var>i</var>).</li></ol></li><li>Let <var>T</var> be the <emu-xref href="#substring" id="_ref_11554"><a href="ecmascript-data-types-and-values.html#substring">substring</a></emu-xref> of <var>S</var> from <var>i</var>.</li><li>Append <var>T</var> to <var>substrings</var>.</li><li>Return <emu-xref aoid="CreateArrayFromList" id="_ref_11555"><a href="abstract-operations.html#sec-createarrayfromlist">CreateArrayFromList</a></emu-xref>(<var>substrings</var>).</li></ol></emu-alg>
|
||
<emu-note><span class="note">Note 1</span><div class="note-contents">
|
||
<p>The value of <var>separator</var> may be an empty String. In this case, <var>separator</var> does not match the empty <emu-not-ref>substring</emu-not-ref> at the beginning or end of the input String, nor does it match the empty <emu-not-ref>substring</emu-not-ref> at the end of the previous separator match. If <var>separator</var> is the empty String, the String is split up into individual code unit elements; the length of the result array equals the length of the String, and each <emu-not-ref>substring</emu-not-ref> contains one code unit.</p>
|
||
<p>If the <emu-val>this</emu-val> value is (or converts to) the empty String, the result depends on whether <var>separator</var> can match the empty String. If it can, the result array contains no elements. Otherwise, the result array contains one element, which is the empty String.</p>
|
||
<p>If <var>separator</var> is <emu-val>undefined</emu-val>, then the result array contains just one String, which is the <emu-val>this</emu-val> value (converted to a String). If <var>limit</var> is not <emu-val>undefined</emu-val>, then the output array is truncated so that it contains no more than <var>limit</var> elements.</p>
|
||
</div></emu-note>
|
||
<emu-note><span class="note">Note 2</span><div class="note-contents">
|
||
<p>This method is intentionally generic; it does not require that its <emu-val>this</emu-val> value be a String object. Therefore, it can be transferred to other kinds of objects for use as a method.</p>
|
||
</div></emu-note>
|
||
</emu-clause>
|
||
|
||
<emu-clause id="sec-string.prototype.startswith" type="built-in function">
|
||
<h1><span class="secnum">22.1.3.24</span> String.prototype.startsWith ( <var>searchString</var> [ , <var>position</var> ] )</h1>
|
||
<p>This method performs the following steps when called:</p>
|
||
<emu-alg><ol><li>Let <var>O</var> be the <emu-val>this</emu-val> value.</li><li>Perform ? <emu-xref aoid="RequireObjectCoercible" id="_ref_11556"><a href="abstract-operations.html#sec-requireobjectcoercible">RequireObjectCoercible</a></emu-xref>(<var>O</var>).</li><li>Let <var>S</var> be ? <emu-xref aoid="ToString" id="_ref_11557"><a href="abstract-operations.html#sec-tostring" class="e-user-code">ToString</a></emu-xref>(<var>O</var>).</li><li>Let <var>isRegExp</var> be ? <emu-xref aoid="IsRegExp" id="_ref_11558"><a href="abstract-operations.html#sec-isregexp" class="e-user-code">IsRegExp</a></emu-xref>(<var>searchString</var>).</li><li>If <var>isRegExp</var> is <emu-val>true</emu-val>, throw a <emu-val>TypeError</emu-val> exception.</li><li>Let <var>searchStr</var> be ? <emu-xref aoid="ToString" id="_ref_11559"><a href="abstract-operations.html#sec-tostring" class="e-user-code">ToString</a></emu-xref>(<var>searchString</var>).</li><li>Let <var>len</var> be the length of <var>S</var>.</li><li>If <var>position</var> is <emu-val>undefined</emu-val>, let <var>pos</var> be 0; else let <var>pos</var> be ? <emu-xref aoid="ToIntegerOrInfinity" id="_ref_11560"><a href="abstract-operations.html#sec-tointegerorinfinity" class="e-user-code">ToIntegerOrInfinity</a></emu-xref>(<var>position</var>).</li><li>Let <var>start</var> be the result of <emu-xref href="#clamping" id="_ref_11561"><a href="notational-conventions.html#clamping">clamping</a></emu-xref> <var>pos</var> between 0 and <var>len</var>.</li><li>Let <var>searchLength</var> be the length of <var>searchStr</var>.</li><li>If <var>searchLength</var> = 0, return <emu-val>true</emu-val>.</li><li>Let <var>end</var> be <var>start</var> + <var>searchLength</var>.</li><li>If <var>end</var> > <var>len</var>, return <emu-val>false</emu-val>.</li><li>Let <var>substring</var> be the <emu-xref href="#substring" id="_ref_11562"><a href="ecmascript-data-types-and-values.html#substring">substring</a></emu-xref> of <var>S</var> from <var>start</var> to <var>end</var>.</li><li>If <var>substring</var> is <var>searchStr</var>, return <emu-val>true</emu-val>.</li><li>Return <emu-val>false</emu-val>.</li></ol></emu-alg>
|
||
<emu-note><span class="note">Note 1</span><div class="note-contents">
|
||
<p>This method returns <emu-val>true</emu-val> if the sequence of code units of <var>searchString</var> converted to a String is the same as the corresponding code units of this object (converted to a String) starting at index <var>position</var>. Otherwise it returns <emu-val>false</emu-val>.</p>
|
||
</div></emu-note>
|
||
<emu-note><span class="note">Note 2</span><div class="note-contents">
|
||
<p>Throwing an exception if the first argument is a RegExp is specified in order to allow future editions to define extensions that allow such argument values.</p>
|
||
</div></emu-note>
|
||
<emu-note><span class="note">Note 3</span><div class="note-contents">
|
||
<p>This method is intentionally generic; it does not require that its <emu-val>this</emu-val> value be a String object. Therefore, it can be transferred to other kinds of objects for use as a method.</p>
|
||
</div></emu-note>
|
||
</emu-clause>
|
||
|
||
<emu-clause id="sec-string.prototype.substring" type="built-in function">
|
||
<h1><span class="secnum">22.1.3.25</span> String.prototype.substring ( <var>start</var>, <var>end</var> )</h1>
|
||
<p>This method returns a <emu-not-ref>substring</emu-not-ref> of the result of converting this object to a String, starting from index <var>start</var> and running to, but not including, index <var>end</var> of the String (or through the end of the String if <var>end</var> is <emu-val>undefined</emu-val>). The result <emu-xref href="#sec-ecmascript-language-types-string-type" id="_ref_11563"><a href="ecmascript-data-types-and-values.html#sec-ecmascript-language-types-string-type">is a String</a></emu-xref> value, not a String object.</p>
|
||
<p>If either argument is <emu-val>NaN</emu-val> or negative, it is replaced with zero; if either argument is strictly greater than the length of the String, it is replaced with the length of the String.</p>
|
||
<p>If <var>start</var> is strictly greater than <var>end</var>, they are swapped.</p>
|
||
<p>It performs the following steps when called:</p>
|
||
<emu-alg><ol><li>Let <var>O</var> be the <emu-val>this</emu-val> value.</li><li>Perform ? <emu-xref aoid="RequireObjectCoercible" id="_ref_11564"><a href="abstract-operations.html#sec-requireobjectcoercible">RequireObjectCoercible</a></emu-xref>(<var>O</var>).</li><li>Let <var>S</var> be ? <emu-xref aoid="ToString" id="_ref_11565"><a href="abstract-operations.html#sec-tostring" class="e-user-code">ToString</a></emu-xref>(<var>O</var>).</li><li>Let <var>len</var> be the length of <var>S</var>.</li><li>Let <var>intStart</var> be ? <emu-xref aoid="ToIntegerOrInfinity" id="_ref_11566"><a href="abstract-operations.html#sec-tointegerorinfinity" class="e-user-code">ToIntegerOrInfinity</a></emu-xref>(<var>start</var>).</li><li>If <var>end</var> is <emu-val>undefined</emu-val>, let <var>intEnd</var> be <var>len</var>; else let <var>intEnd</var> be ? <emu-xref aoid="ToIntegerOrInfinity" id="_ref_11567"><a href="abstract-operations.html#sec-tointegerorinfinity" class="e-user-code">ToIntegerOrInfinity</a></emu-xref>(<var>end</var>).</li><li>Let <var>finalStart</var> be the result of <emu-xref href="#clamping" id="_ref_11568"><a href="notational-conventions.html#clamping">clamping</a></emu-xref> <var>intStart</var> between 0 and <var>len</var>.</li><li>Let <var>finalEnd</var> be the result of <emu-xref href="#clamping" id="_ref_11569"><a href="notational-conventions.html#clamping">clamping</a></emu-xref> <var>intEnd</var> between 0 and <var>len</var>.</li><li>Let <var>from</var> be <emu-xref aoid="min" id="_ref_11570"><a href="notational-conventions.html#eqn-min">min</a></emu-xref>(<var>finalStart</var>, <var>finalEnd</var>).</li><li>Let <var>to</var> be <emu-xref aoid="max" id="_ref_11571"><a href="notational-conventions.html#eqn-max">max</a></emu-xref>(<var>finalStart</var>, <var>finalEnd</var>).</li><li>Return the <emu-xref href="#substring" id="_ref_11572"><a href="ecmascript-data-types-and-values.html#substring">substring</a></emu-xref> of <var>S</var> from <var>from</var> to <var>to</var>.</li></ol></emu-alg>
|
||
<emu-note><span class="note">Note</span><div class="note-contents">
|
||
<p>This method is intentionally generic; it does not require that its <emu-val>this</emu-val> value be a String object. Therefore, it can be transferred to other kinds of objects for use as a method.</p>
|
||
</div></emu-note>
|
||
</emu-clause>
|
||
|
||
<emu-clause id="sec-string.prototype.tolocalelowercase" type="built-in function">
|
||
<h1><span class="secnum">22.1.3.26</span> String.prototype.toLocaleLowerCase ( [ <var>reserved1</var> [ , <var>reserved2</var> ] ] )</h1>
|
||
<p>An ECMAScript implementation that includes the ECMA-402 Internationalization API must implement this method as specified in the ECMA-402 specification. If an ECMAScript implementation does not include the ECMA-402 API the following specification of this method is used:</p>
|
||
<p>This method interprets a String value as a sequence of UTF-16 encoded code points, as described in <emu-xref href="#sec-ecmascript-language-types-string-type" id="_ref_662"><a href="ecmascript-data-types-and-values.html#sec-ecmascript-language-types-string-type">6.1.4</a></emu-xref>.</p>
|
||
<p>It works exactly the same as <code>toLowerCase</code> except that it is intended to yield a locale-sensitive result corresponding with conventions of the <emu-xref href="#host-environment" id="_ref_11573"><a href="overview.html#host-environment">host environment</a></emu-xref>'s current locale. There will only be a difference in the few cases (such as Turkish) where the rules for that language conflict with the regular Unicode case mappings.</p>
|
||
<p>The meaning of the optional parameters to this method are defined in the ECMA-402 specification; implementations that do not include ECMA-402 support must not use those parameter positions for anything else.</p>
|
||
<emu-note><span class="note">Note</span><div class="note-contents">
|
||
<p>This method is intentionally generic; it does not require that its <emu-val>this</emu-val> value be a String object. Therefore, it can be transferred to other kinds of objects for use as a method.</p>
|
||
</div></emu-note>
|
||
</emu-clause>
|
||
|
||
<emu-clause id="sec-string.prototype.tolocaleuppercase" type="built-in function">
|
||
<h1><span class="secnum">22.1.3.27</span> String.prototype.toLocaleUpperCase ( [ <var>reserved1</var> [ , <var>reserved2</var> ] ] )</h1>
|
||
<p>An ECMAScript implementation that includes the ECMA-402 Internationalization API must implement this method as specified in the ECMA-402 specification. If an ECMAScript implementation does not include the ECMA-402 API the following specification of this method is used:</p>
|
||
<p>This method interprets a String value as a sequence of UTF-16 encoded code points, as described in <emu-xref href="#sec-ecmascript-language-types-string-type" id="_ref_663"><a href="ecmascript-data-types-and-values.html#sec-ecmascript-language-types-string-type">6.1.4</a></emu-xref>.</p>
|
||
<p>It works exactly the same as <code>toUpperCase</code> except that it is intended to yield a locale-sensitive result corresponding with conventions of the <emu-xref href="#host-environment" id="_ref_11574"><a href="overview.html#host-environment">host environment</a></emu-xref>'s current locale. There will only be a difference in the few cases (such as Turkish) where the rules for that language conflict with the regular Unicode case mappings.</p>
|
||
<p>The meaning of the optional parameters to this method are defined in the ECMA-402 specification; implementations that do not include ECMA-402 support must not use those parameter positions for anything else.</p>
|
||
<emu-note><span class="note">Note</span><div class="note-contents">
|
||
<p>This method is intentionally generic; it does not require that its <emu-val>this</emu-val> value be a String object. Therefore, it can be transferred to other kinds of objects for use as a method.</p>
|
||
</div></emu-note>
|
||
</emu-clause>
|
||
|
||
<emu-clause id="sec-string.prototype.tolowercase" type="built-in function">
|
||
<h1><span class="secnum">22.1.3.28</span> String.prototype.toLowerCase ( )</h1>
|
||
<p>This method interprets a String value as a sequence of UTF-16 encoded code points, as described in <emu-xref href="#sec-ecmascript-language-types-string-type" id="_ref_664"><a href="ecmascript-data-types-and-values.html#sec-ecmascript-language-types-string-type">6.1.4</a></emu-xref>.</p>
|
||
<p>It performs the following steps when called:</p>
|
||
<emu-alg><ol><li>Let <var>O</var> be the <emu-val>this</emu-val> value.</li><li>Perform ? <emu-xref aoid="RequireObjectCoercible" id="_ref_11575"><a href="abstract-operations.html#sec-requireobjectcoercible">RequireObjectCoercible</a></emu-xref>(<var>O</var>).</li><li>Let <var>S</var> be ? <emu-xref aoid="ToString" id="_ref_11576"><a href="abstract-operations.html#sec-tostring" class="e-user-code">ToString</a></emu-xref>(<var>O</var>).</li><li>Let <var>sText</var> be <emu-xref aoid="StringToCodePoints" id="_ref_11577"><a href="ecmascript-language-source-code.html#sec-stringtocodepoints">StringToCodePoints</a></emu-xref>(<var>S</var>).</li><li>Let <var>lowerText</var> be toLowercase(<var>sText</var>), according to the Unicode Default Case Conversion algorithm.</li><li>Let <var>L</var> be <emu-xref aoid="CodePointsToString" id="_ref_11578"><a href="ecmascript-language-source-code.html#sec-codepointstostring">CodePointsToString</a></emu-xref>(<var>lowerText</var>).</li><li>Return <var>L</var>.</li></ol></emu-alg>
|
||
<p>The result must be derived according to the locale-insensitive case mappings in the Unicode Character Database (this explicitly includes not only the file <a href="https://unicode.org/Public/UCD/latest/ucd/UnicodeData.txt"><code>UnicodeData.txt</code></a>, but also all locale-insensitive mappings in the file <a href="https://unicode.org/Public/UCD/latest/ucd/SpecialCasing.txt"><code>SpecialCasing.txt</code></a> that accompanies it).</p>
|
||
<emu-note><span class="note">Note 1</span><div class="note-contents">
|
||
<p>The case mapping of some code points may produce multiple code points. In this case the result String may not be the same length as the source String. Because both <code>toUpperCase</code> and <code>toLowerCase</code> have context-sensitive behaviour, the methods are not symmetrical. In other words, <code>s.toUpperCase().toLowerCase()</code> is not necessarily equal to <code>s.toLowerCase()</code>.</p>
|
||
</div></emu-note>
|
||
<emu-note><span class="note">Note 2</span><div class="note-contents">
|
||
<p>This method is intentionally generic; it does not require that its <emu-val>this</emu-val> value be a String object. Therefore, it can be transferred to other kinds of objects for use as a method.</p>
|
||
</div></emu-note>
|
||
</emu-clause>
|
||
|
||
<emu-clause id="sec-string.prototype.tostring" type="built-in function">
|
||
<h1><span class="secnum">22.1.3.29</span> String.prototype.toString ( )</h1>
|
||
<p>This method performs the following steps when called:</p>
|
||
<emu-alg><ol><li>Return ? <emu-xref aoid="ThisStringValue" id="_ref_11579"><a href="text-processing.html#sec-thisstringvalue">ThisStringValue</a></emu-xref>(<emu-val>this</emu-val> value).</li></ol></emu-alg>
|
||
<emu-note><span class="note">Note</span><div class="note-contents">
|
||
<p>For a String object, this method happens to return the same thing as the <code>valueOf</code> method.</p>
|
||
</div></emu-note>
|
||
</emu-clause>
|
||
|
||
<emu-clause id="sec-string.prototype.touppercase" type="built-in function">
|
||
<h1><span class="secnum">22.1.3.30</span> String.prototype.toUpperCase ( )</h1>
|
||
<p>This method interprets a String value as a sequence of UTF-16 encoded code points, as described in <emu-xref href="#sec-ecmascript-language-types-string-type" id="_ref_665"><a href="ecmascript-data-types-and-values.html#sec-ecmascript-language-types-string-type">6.1.4</a></emu-xref>.</p>
|
||
<p>It behaves in exactly the same way as <code>String.prototype.toLowerCase</code>, except that the String is mapped using the toUppercase algorithm of the Unicode Default Case Conversion.</p>
|
||
<emu-note><span class="note">Note</span><div class="note-contents">
|
||
<p>This method is intentionally generic; it does not require that its <emu-val>this</emu-val> value be a String object. Therefore, it can be transferred to other kinds of objects for use as a method.</p>
|
||
</div></emu-note>
|
||
</emu-clause>
|
||
|
||
<emu-clause id="sec-string.prototype.towellformed" type="built-in function">
|
||
<h1><span class="secnum">22.1.3.31</span> String.prototype.toWellFormed ( )</h1>
|
||
<p>This method returns a String representation of this object with all <emu-xref href="#leading-surrogate" id="_ref_11580"><a href="ecmascript-data-types-and-values.html#leading-surrogate">leading surrogates</a></emu-xref> and <emu-xref href="#trailing-surrogate" id="_ref_11581"><a href="ecmascript-data-types-and-values.html#trailing-surrogate">trailing surrogates</a></emu-xref> that are not part of a <emu-xref href="#surrogate-pair" id="_ref_11582"><a href="ecmascript-data-types-and-values.html#surrogate-pair">surrogate pair</a></emu-xref> replaced with U+FFFD (REPLACEMENT CHARACTER).</p>
|
||
<p>It performs the following steps when called:</p>
|
||
<emu-alg><ol><li>Let <var>O</var> be the <emu-val>this</emu-val> value.</li><li>Perform ? <emu-xref aoid="RequireObjectCoercible" id="_ref_11583"><a href="abstract-operations.html#sec-requireobjectcoercible">RequireObjectCoercible</a></emu-xref>(<var>O</var>).</li><li>Let <var>S</var> be ? <emu-xref aoid="ToString" id="_ref_11584"><a href="abstract-operations.html#sec-tostring" class="e-user-code">ToString</a></emu-xref>(<var>O</var>).</li><li>Let <var>strLen</var> be the length of <var>S</var>.</li><li>Let <var>k</var> be 0.</li><li>Let <var>result</var> be the empty String.</li><li>Repeat, while <var>k</var> < <var>strLen</var>,<ol><li>Let <var>cp</var> be <emu-xref aoid="CodePointAt" id="_ref_11585"><a href="ecmascript-language-source-code.html#sec-codepointat">CodePointAt</a></emu-xref>(<var>S</var>, <var>k</var>).</li><li>If <var>cp</var>.<var class="field">[[IsUnpairedSurrogate]]</var> is <emu-val>true</emu-val>, then<ol><li>Set <var>result</var> to the <emu-xref href="#string-concatenation" id="_ref_11586"><a href="ecmascript-data-types-and-values.html#string-concatenation">string-concatenation</a></emu-xref> of <var>result</var> and 0xFFFD (REPLACEMENT CHARACTER).</li></ol></li><li>Else,<ol><li>Set <var>result</var> to the <emu-xref href="#string-concatenation" id="_ref_11587"><a href="ecmascript-data-types-and-values.html#string-concatenation">string-concatenation</a></emu-xref> of <var>result</var> and <emu-xref aoid="UTF16EncodeCodePoint" id="_ref_11588"><a href="ecmascript-language-source-code.html#sec-utf16encodecodepoint">UTF16EncodeCodePoint</a></emu-xref>(<var>cp</var>.<var class="field">[[CodePoint]]</var>).</li></ol></li><li>Set <var>k</var> to <var>k</var> + <var>cp</var>.<var class="field">[[CodeUnitCount]]</var>.</li></ol></li><li>Return <var>result</var>.</li></ol></emu-alg>
|
||
</emu-clause>
|
||
|
||
<emu-clause id="sec-string.prototype.trim" type="built-in function">
|
||
<h1><span class="secnum">22.1.3.32</span> String.prototype.trim ( )</h1>
|
||
<p>This method interprets a String value as a sequence of UTF-16 encoded code points, as described in <emu-xref href="#sec-ecmascript-language-types-string-type" id="_ref_666"><a href="ecmascript-data-types-and-values.html#sec-ecmascript-language-types-string-type">6.1.4</a></emu-xref>.</p>
|
||
<p>It performs the following steps when called:</p>
|
||
<emu-alg><ol><li>Let <var>S</var> be the <emu-val>this</emu-val> value.</li><li>Return ? <emu-xref aoid="TrimString" id="_ref_11589"><a href="text-processing.html#sec-trimstring" class="e-user-code">TrimString</a></emu-xref>(<var>S</var>, <emu-const>start+end</emu-const>).</li></ol></emu-alg>
|
||
<emu-note><span class="note">Note</span><div class="note-contents">
|
||
<p>This method is intentionally generic; it does not require that its <emu-val>this</emu-val> value be a String object. Therefore, it can be transferred to other kinds of objects for use as a method.</p>
|
||
</div></emu-note>
|
||
|
||
<emu-clause id="sec-trimstring" type="abstract operation" aoid="TrimString">
|
||
<h1><span class="secnum">22.1.3.32.1</span> TrimString ( <var>string</var>, <var>where</var> )</h1>
|
||
<p>The abstract operation TrimString takes arguments <var>string</var> (an <emu-xref href="#sec-ecmascript-language-types" id="_ref_11590"><a href="ecmascript-data-types-and-values.html#sec-ecmascript-language-types">ECMAScript language value</a></emu-xref>) and <var>where</var> (<emu-const>start</emu-const>, <emu-const>end</emu-const>, or <emu-const>start+end</emu-const>) and returns either a <emu-xref href="#sec-completion-record-specification-type" id="_ref_11591"><a href="ecmascript-data-types-and-values.html#sec-completion-record-specification-type">normal completion containing</a></emu-xref> a String or a <emu-xref href="#sec-completion-record-specification-type" id="_ref_11592"><a href="ecmascript-data-types-and-values.html#sec-completion-record-specification-type">throw completion</a></emu-xref>. It interprets <var>string</var> as a sequence of UTF-16 encoded code points, as described in <emu-xref href="#sec-ecmascript-language-types-string-type" id="_ref_667"><a href="ecmascript-data-types-and-values.html#sec-ecmascript-language-types-string-type">6.1.4</a></emu-xref>. It performs the following steps when called:</p>
|
||
<emu-alg><ol><li>Perform ? <emu-xref aoid="RequireObjectCoercible" id="_ref_11593"><a href="abstract-operations.html#sec-requireobjectcoercible">RequireObjectCoercible</a></emu-xref>(<var>string</var>).</li><li>Let <var>S</var> be ? <emu-xref aoid="ToString" id="_ref_11594"><a href="abstract-operations.html#sec-tostring" class="e-user-code">ToString</a></emu-xref>(<var>string</var>).</li><li>If <var>where</var> is <emu-const>start</emu-const>, then<ol><li>Let <var>T</var> be the String value that is a copy of <var>S</var> with leading white space removed.</li></ol></li><li>Else if <var>where</var> is <emu-const>end</emu-const>, then<ol><li>Let <var>T</var> be the String value that is a copy of <var>S</var> with trailing white space removed.</li></ol></li><li>Else,<ol><li><emu-xref href="#assert" id="_ref_11595"><a href="notational-conventions.html#assert">Assert</a></emu-xref>: <var>where</var> is <emu-const>start+end</emu-const>.</li><li>Let <var>T</var> be the String value that is a copy of <var>S</var> with both leading and trailing white space removed.</li></ol></li><li>Return <var>T</var>.</li></ol></emu-alg>
|
||
<p>The definition of white space is the union of <emu-nt id="_ref_23935"><a href="ecmascript-language-lexical-grammar.html#prod-WhiteSpace">WhiteSpace</a></emu-nt> and <emu-nt id="_ref_23936"><a href="ecmascript-language-lexical-grammar.html#prod-LineTerminator">LineTerminator</a></emu-nt>. When determining whether a Unicode code point is in Unicode general category “Space_Separator” (“Zs”), code unit sequences are interpreted as UTF-16 encoded code point sequences as specified in <emu-xref href="#sec-ecmascript-language-types-string-type" id="_ref_668"><a href="ecmascript-data-types-and-values.html#sec-ecmascript-language-types-string-type">6.1.4</a></emu-xref>.</p>
|
||
</emu-clause>
|
||
</emu-clause>
|
||
|
||
<emu-clause id="sec-string.prototype.trimend" type="built-in function">
|
||
<h1><span class="secnum">22.1.3.33</span> String.prototype.trimEnd ( )</h1>
|
||
<p>This method interprets a String value as a sequence of UTF-16 encoded code points, as described in <emu-xref href="#sec-ecmascript-language-types-string-type" id="_ref_669"><a href="ecmascript-data-types-and-values.html#sec-ecmascript-language-types-string-type">6.1.4</a></emu-xref>.</p>
|
||
<p>It performs the following steps when called:</p>
|
||
<emu-alg><ol><li>Let <var>S</var> be the <emu-val>this</emu-val> value.</li><li>Return ? <emu-xref aoid="TrimString" id="_ref_11596"><a href="text-processing.html#sec-trimstring" class="e-user-code">TrimString</a></emu-xref>(<var>S</var>, <emu-const>end</emu-const>).</li></ol></emu-alg>
|
||
<emu-note><span class="note">Note</span><div class="note-contents">
|
||
<p>This method is intentionally generic; it does not require that its <emu-val>this</emu-val> value be a String object. Therefore, it can be transferred to other kinds of objects for use as a method.</p>
|
||
</div></emu-note>
|
||
</emu-clause>
|
||
|
||
<emu-clause id="sec-string.prototype.trimstart" type="built-in function">
|
||
<h1><span class="secnum">22.1.3.34</span> String.prototype.trimStart ( )</h1>
|
||
<p>This method interprets a String value as a sequence of UTF-16 encoded code points, as described in <emu-xref href="#sec-ecmascript-language-types-string-type" id="_ref_670"><a href="ecmascript-data-types-and-values.html#sec-ecmascript-language-types-string-type">6.1.4</a></emu-xref>.</p>
|
||
<p>It performs the following steps when called:</p>
|
||
<emu-alg><ol><li>Let <var>S</var> be the <emu-val>this</emu-val> value.</li><li>Return ? <emu-xref aoid="TrimString" id="_ref_11597"><a href="text-processing.html#sec-trimstring" class="e-user-code">TrimString</a></emu-xref>(<var>S</var>, <emu-const>start</emu-const>).</li></ol></emu-alg>
|
||
<emu-note><span class="note">Note</span><div class="note-contents">
|
||
<p>This method is intentionally generic; it does not require that its <emu-val>this</emu-val> value be a String object. Therefore, it can be transferred to other kinds of objects for use as a method.</p>
|
||
</div></emu-note>
|
||
</emu-clause>
|
||
|
||
<emu-clause id="sec-string.prototype.valueof" type="built-in function">
|
||
<h1><span class="secnum">22.1.3.35</span> String.prototype.valueOf ( )</h1>
|
||
<p>This method performs the following steps when called:</p>
|
||
<emu-alg><ol><li>Return ? <emu-xref aoid="ThisStringValue" id="_ref_11598"><a href="text-processing.html#sec-thisstringvalue">ThisStringValue</a></emu-xref>(<emu-val>this</emu-val> value).</li></ol></emu-alg>
|
||
|
||
<emu-clause id="sec-thisstringvalue" type="abstract operation" oldids="thisstringvalue" aoid="ThisStringValue"><span id="thisstringvalue"></span>
|
||
<h1><span class="secnum">22.1.3.35.1</span> ThisStringValue ( <var>value</var> )</h1>
|
||
<p>The abstract operation ThisStringValue takes argument <var>value</var> (an <emu-xref href="#sec-ecmascript-language-types" id="_ref_11599"><a href="ecmascript-data-types-and-values.html#sec-ecmascript-language-types">ECMAScript language value</a></emu-xref>) and returns either a <emu-xref href="#sec-completion-record-specification-type" id="_ref_11600"><a href="ecmascript-data-types-and-values.html#sec-completion-record-specification-type">normal completion containing</a></emu-xref> a String or a <emu-xref href="#sec-completion-record-specification-type" id="_ref_11601"><a href="ecmascript-data-types-and-values.html#sec-completion-record-specification-type">throw completion</a></emu-xref>. It performs the following steps when called:</p>
|
||
<emu-alg><ol><li>If <var>value</var> <emu-xref href="#sec-ecmascript-language-types-string-type" id="_ref_11602"><a href="ecmascript-data-types-and-values.html#sec-ecmascript-language-types-string-type">is a String</a></emu-xref>, return <var>value</var>.</li><li>If <var>value</var> <emu-xref href="#sec-object-type" id="_ref_11603"><a href="ecmascript-data-types-and-values.html#sec-object-type">is an Object</a></emu-xref> and <var>value</var> has a <var class="field">[[StringData]]</var> internal slot, then<ol><li>Let <var>s</var> be <var>value</var>.<var class="field">[[StringData]]</var>.</li><li><emu-xref href="#assert" id="_ref_11604"><a href="notational-conventions.html#assert">Assert</a></emu-xref>: <var>s</var> <emu-xref href="#sec-ecmascript-language-types-string-type" id="_ref_11605"><a href="ecmascript-data-types-and-values.html#sec-ecmascript-language-types-string-type">is a String</a></emu-xref>.</li><li>Return <var>s</var>.</li></ol></li><li>Throw a <emu-val>TypeError</emu-val> exception.</li></ol></emu-alg>
|
||
</emu-clause>
|
||
</emu-clause>
|
||
|
||
<emu-clause id="sec-string.prototype-%symbol.iterator%" oldids="sec-string.prototype-@@iterator,sec-createstringiterator,sec-properties-of-string-iterator-instances,table-46,table-internal-slots-of-string-iterator-instances" type="built-in function"><span id="table-internal-slots-of-string-iterator-instances"></span><span id="table-46"></span><span id="sec-properties-of-string-iterator-instances"></span><span id="sec-createstringiterator"></span><span id="sec-string.prototype-@@iterator"></span>
|
||
<h1><span class="secnum">22.1.3.36</span> String.prototype [ %Symbol.iterator% ] ( )</h1>
|
||
<p>This method returns an <emu-xref href="#sec-iterator-interface" id="_ref_11606"><a href="control-abstraction-objects.html#sec-iterator-interface">iterator object</a></emu-xref> that iterates over the code points of a String value, returning each code point as a String value.</p>
|
||
<p>It performs the following steps when called:</p>
|
||
<emu-alg><ol><li>Let <var>O</var> be the <emu-val>this</emu-val> value.</li><li>Perform ? <emu-xref aoid="RequireObjectCoercible" id="_ref_11607"><a href="abstract-operations.html#sec-requireobjectcoercible">RequireObjectCoercible</a></emu-xref>(<var>O</var>).</li><li>Let <var>s</var> be ? <emu-xref aoid="ToString" id="_ref_11608"><a href="abstract-operations.html#sec-tostring" class="e-user-code">ToString</a></emu-xref>(<var>O</var>).</li><li>Let <var>closure</var> be a new <emu-xref href="#sec-abstract-closure" id="_ref_11609"><a href="ecmascript-data-types-and-values.html#sec-abstract-closure">Abstract Closure</a></emu-xref> with no parameters that captures <var>s</var> and performs the following steps when called:<ol><li>Let <var>len</var> be the length of <var>s</var>.</li><li>Let <var>position</var> be 0.</li><li>Repeat, while <var>position</var> < <var>len</var>,<ol><li>Let <var>cp</var> be <emu-xref aoid="CodePointAt" id="_ref_11610"><a href="ecmascript-language-source-code.html#sec-codepointat">CodePointAt</a></emu-xref>(<var>s</var>, <var>position</var>).</li><li>Let <var>nextIndex</var> be <var>position</var> + <var>cp</var>.<var class="field">[[CodeUnitCount]]</var>.</li><li>Let <var>resultString</var> be the <emu-xref href="#substring" id="_ref_11611"><a href="ecmascript-data-types-and-values.html#substring">substring</a></emu-xref> of <var>s</var> from <var>position</var> to <var>nextIndex</var>.</li><li>Set <var>position</var> to <var>nextIndex</var>.</li><li>Perform ? <emu-xref aoid="GeneratorYield" id="_ref_11612"><a href="control-abstraction-objects.html#sec-generatoryield">GeneratorYield</a></emu-xref>(<emu-xref aoid="CreateIteratorResultObject" id="_ref_11613"><a href="abstract-operations.html#sec-createiterresultobject">CreateIteratorResultObject</a></emu-xref>(<var>resultString</var>, <emu-val>false</emu-val>)).</li></ol></li><li>Return <emu-xref aoid="NormalCompletion" id="_ref_11614"><a href="ecmascript-data-types-and-values.html#sec-normalcompletion">NormalCompletion</a></emu-xref>(<emu-const>unused</emu-const>).</li></ol></li><li>Return <emu-xref aoid="CreateIteratorFromClosure" id="_ref_11615"><a href="control-abstraction-objects.html#sec-createiteratorfromclosure">CreateIteratorFromClosure</a></emu-xref>(<var>closure</var>, <emu-val>"%StringIteratorPrototype%"</emu-val>, <emu-xref href="#sec-%stringiteratorprototype%-object" id="_ref_11616"><a href="text-processing.html#sec-%stringiteratorprototype%-object">%StringIteratorPrototype%</a></emu-xref>).</li></ol></emu-alg>
|
||
<p>The value of the <emu-val>"name"</emu-val> property of this method is <emu-val>"[Symbol.iterator]"</emu-val>.</p>
|
||
</emu-clause>
|
||
</emu-clause>
|
||
|
||
<emu-clause id="sec-properties-of-string-instances">
|
||
<h1><span class="secnum">22.1.4</span> Properties of String Instances</h1>
|
||
<p>String instances are <emu-xref href="#string-exotic-object" id="_ref_11617"><a href="ordinary-and-exotic-objects-behaviours.html#string-exotic-object">String exotic objects</a></emu-xref> and have the internal methods specified for such objects. String instances inherit properties from the <emu-xref href="#sec-properties-of-the-string-prototype-object" id="_ref_11618"><a href="text-processing.html#sec-properties-of-the-string-prototype-object">String prototype object</a></emu-xref>. String instances also have a <var class="field">[[StringData]]</var> internal slot. The <var class="field">[[StringData]]</var> internal slot is the String value represented by this String object.</p>
|
||
<p>String instances have a <emu-val>"length"</emu-val> property, and a set of enumerable properties with <emu-xref href="#integer-index" id="_ref_11619"><a href="ecmascript-data-types-and-values.html#integer-index">integer-indexed</a></emu-xref> names.</p>
|
||
|
||
<emu-clause id="sec-properties-of-string-instances-length">
|
||
<h1><span class="secnum">22.1.4.1</span> length</h1>
|
||
<p>The number of elements in the String value represented by this String object.</p>
|
||
<p>Once a String object is initialized, this property is unchanging. It has the attributes { <var class="field">[[Writable]]</var>: <emu-val>false</emu-val>, <var class="field">[[Enumerable]]</var>: <emu-val>false</emu-val>, <var class="field">[[Configurable]]</var>: <emu-val>false</emu-val> }.</p>
|
||
</emu-clause>
|
||
</emu-clause>
|
||
|
||
<emu-clause id="sec-string-iterator-objects">
|
||
<h1><span class="secnum">22.1.5</span> String Iterator Objects</h1>
|
||
<p>A <dfn variants="String Iterators,String Iterator object,String Iterator objects" tabindex="-1">String Iterator</dfn> is an object that represents a specific iteration over some specific String instance object. There is not a named <emu-xref href="#constructor" id="_ref_11620"><a href="ecmascript-data-types-and-values.html#constructor">constructor</a></emu-xref> for String Iterator objects. Instead, String Iterator objects are created by calling certain methods of String instance objects.</p>
|
||
|
||
<emu-clause id="sec-%stringiteratorprototype%-object">
|
||
<h1><span class="secnum">22.1.5.1</span> The %StringIteratorPrototype% Object</h1>
|
||
<p>The <dfn tabindex="-1">%StringIteratorPrototype%</dfn> object:</p>
|
||
<ul>
|
||
<li>has properties that are inherited by all <emu-xref href="#sec-string-iterator-objects" id="_ref_11621"><a href="text-processing.html#sec-string-iterator-objects">String Iterator objects</a></emu-xref>.</li>
|
||
<li>is an <emu-xref href="#ordinary-object" id="_ref_11622"><a href="ecmascript-data-types-and-values.html#ordinary-object">ordinary object</a></emu-xref>.</li>
|
||
<li>has a <var class="field">[[Prototype]]</var> internal slot whose value is <emu-xref href="#sec-%iterator.prototype%-object" id="_ref_11623"><a href="control-abstraction-objects.html#sec-%iterator.prototype%-object">%Iterator.prototype%</a></emu-xref>.</li>
|
||
<li>has the following properties:</li>
|
||
</ul>
|
||
|
||
<emu-clause id="sec-%stringiteratorprototype%.next" type="built-in function">
|
||
<h1><span class="secnum">22.1.5.1.1</span> %StringIteratorPrototype%.next ( )</h1>
|
||
<emu-alg><ol><li>Return ? <emu-xref aoid="GeneratorResume" id="_ref_11624"><a href="control-abstraction-objects.html#sec-generatorresume">GeneratorResume</a></emu-xref>(<emu-val>this</emu-val> value, <emu-const>empty</emu-const>, <emu-val>"%StringIteratorPrototype%"</emu-val>).</li></ol></emu-alg>
|
||
</emu-clause>
|
||
|
||
<emu-clause oldids="sec-%stringiteratorprototype%-@@tostringtag" id="sec-%stringiteratorprototype%-%symbol.tostringtag%"><span id="sec-%stringiteratorprototype%-@@tostringtag"></span>
|
||
<h1><span class="secnum">22.1.5.1.2</span> %StringIteratorPrototype% [ %Symbol.toStringTag% ]</h1>
|
||
<p>The initial value of the <emu-xref href="#sec-well-known-symbols" id="_ref_11625"><a href="ecmascript-data-types-and-values.html#sec-well-known-symbols">%Symbol.toStringTag%</a></emu-xref> property is the String value <emu-val>"String Iterator"</emu-val>.</p>
|
||
<p>This property has the attributes { <var class="field">[[Writable]]</var>: <emu-val>false</emu-val>, <var class="field">[[Enumerable]]</var>: <emu-val>false</emu-val>, <var class="field">[[Configurable]]</var>: <emu-val>true</emu-val> }.</p>
|
||
</emu-clause>
|
||
</emu-clause>
|
||
</emu-clause>
|
||
</emu-clause>
|
||
|
||
<emu-clause id="sec-regexp-regular-expression-objects">
|
||
<h1><span class="secnum">22.2</span> RegExp (Regular Expression) Objects</h1>
|
||
<p>A RegExp object contains a regular expression and the associated flags.</p>
|
||
<emu-note><span class="note">Note</span><div class="note-contents">
|
||
<p>The form and functionality of regular expressions is modelled after the regular expression facility in the Perl 5 programming language.</p>
|
||
</div></emu-note>
|
||
|
||
<emu-clause id="sec-patterns">
|
||
<h1><span class="secnum">22.2.1</span> Patterns</h1>
|
||
<p>The RegExp <emu-xref href="#constructor" id="_ref_11626"><a href="ecmascript-data-types-and-values.html#constructor">constructor</a></emu-xref> applies the following grammar to the input pattern String. An error occurs if the grammar cannot interpret the String as an expansion of <emu-nt id="_ref_23937"><a href="text-processing.html#prod-Pattern">Pattern</a></emu-nt>.</p>
|
||
<h2>Syntax</h2>
|
||
<emu-grammar type="definition"><emu-production name="Pattern" params="UnicodeMode, UnicodeSetsMode, NamedCaptureGroups" type="lexical" id="prod-Pattern">
|
||
<emu-nt params="UnicodeMode, UnicodeSetsMode, NamedCaptureGroups"><a href="text-processing.html#prod-Pattern">Pattern</a><emu-mods><emu-params>[UnicodeMode, UnicodeSetsMode, NamedCaptureGroups]</emu-params></emu-mods></emu-nt> <emu-geq>::</emu-geq> <emu-rhs a="qykacx9h" id="prod-B7AwVhmt">
|
||
<emu-nt params="?UnicodeMode, ?UnicodeSetsMode, ?NamedCaptureGroups" id="_ref_23938"><a href="text-processing.html#prod-Disjunction">Disjunction</a><emu-mods><emu-params>[?UnicodeMode, ?UnicodeSetsMode, ?NamedCaptureGroups]</emu-params></emu-mods></emu-nt>
|
||
</emu-rhs>
|
||
</emu-production>
|
||
<emu-production name="Disjunction" params="UnicodeMode, UnicodeSetsMode, NamedCaptureGroups" type="lexical" id="prod-Disjunction">
|
||
<emu-nt params="UnicodeMode, UnicodeSetsMode, NamedCaptureGroups"><a href="text-processing.html#prod-Disjunction">Disjunction</a><emu-mods><emu-params>[UnicodeMode, UnicodeSetsMode, NamedCaptureGroups]</emu-params></emu-mods></emu-nt> <emu-geq>::</emu-geq> <emu-rhs a="4qtdrfbm">
|
||
<emu-nt params="?UnicodeMode, ?UnicodeSetsMode, ?NamedCaptureGroups" id="_ref_23939"><a href="text-processing.html#prod-Alternative">Alternative</a><emu-mods><emu-params>[?UnicodeMode, ?UnicodeSetsMode, ?NamedCaptureGroups]</emu-params></emu-mods></emu-nt>
|
||
</emu-rhs>
|
||
<emu-rhs a="tuo0qrl_" id="prod-MCRqOZOt">
|
||
<emu-nt params="?UnicodeMode, ?UnicodeSetsMode, ?NamedCaptureGroups" id="_ref_23940"><a href="text-processing.html#prod-Alternative">Alternative</a><emu-mods><emu-params>[?UnicodeMode, ?UnicodeSetsMode, ?NamedCaptureGroups]</emu-params></emu-mods></emu-nt>
|
||
<emu-t>|</emu-t>
|
||
<emu-nt params="?UnicodeMode, ?UnicodeSetsMode, ?NamedCaptureGroups" id="_ref_23941"><a href="text-processing.html#prod-Disjunction">Disjunction</a><emu-mods><emu-params>[?UnicodeMode, ?UnicodeSetsMode, ?NamedCaptureGroups]</emu-params></emu-mods></emu-nt>
|
||
</emu-rhs>
|
||
</emu-production>
|
||
<emu-production name="Alternative" params="UnicodeMode, UnicodeSetsMode, NamedCaptureGroups" type="lexical" id="prod-Alternative">
|
||
<emu-nt params="UnicodeMode, UnicodeSetsMode, NamedCaptureGroups"><a href="text-processing.html#prod-Alternative">Alternative</a><emu-mods><emu-params>[UnicodeMode, UnicodeSetsMode, NamedCaptureGroups]</emu-params></emu-mods></emu-nt> <emu-geq>::</emu-geq> <emu-rhs a="n7nathbb" id="prod-59aIYYAE">
|
||
<emu-gann>[empty]</emu-gann>
|
||
</emu-rhs>
|
||
<emu-rhs a="tjzxuhbg" id="prod-AWMX5oRX">
|
||
<emu-nt params="?UnicodeMode, ?UnicodeSetsMode, ?NamedCaptureGroups" id="_ref_23942"><a href="text-processing.html#prod-Alternative">Alternative</a><emu-mods><emu-params>[?UnicodeMode, ?UnicodeSetsMode, ?NamedCaptureGroups]</emu-params></emu-mods></emu-nt>
|
||
<emu-nt params="?UnicodeMode, ?UnicodeSetsMode, ?NamedCaptureGroups" id="_ref_23943"><a href="text-processing.html#prod-Term">Term</a><emu-mods><emu-params>[?UnicodeMode, ?UnicodeSetsMode, ?NamedCaptureGroups]</emu-params></emu-mods></emu-nt>
|
||
</emu-rhs>
|
||
</emu-production>
|
||
<emu-production name="Term" params="UnicodeMode, UnicodeSetsMode, NamedCaptureGroups" type="lexical" id="prod-Term">
|
||
<emu-nt params="UnicodeMode, UnicodeSetsMode, NamedCaptureGroups"><a href="text-processing.html#prod-Term">Term</a><emu-mods><emu-params>[UnicodeMode, UnicodeSetsMode, NamedCaptureGroups]</emu-params></emu-mods></emu-nt> <emu-geq>::</emu-geq> <emu-rhs a="csnnrw7w" id="prod-R1uQAeY_">
|
||
<emu-nt params="?UnicodeMode, ?UnicodeSetsMode, ?NamedCaptureGroups" id="_ref_23944"><a href="text-processing.html#prod-Assertion">Assertion</a><emu-mods><emu-params>[?UnicodeMode, ?UnicodeSetsMode, ?NamedCaptureGroups]</emu-params></emu-mods></emu-nt>
|
||
</emu-rhs>
|
||
<emu-rhs a="xwd77nef" id="prod-j_jePxdh">
|
||
<emu-nt params="?UnicodeMode, ?UnicodeSetsMode, ?NamedCaptureGroups" id="_ref_23945"><a href="text-processing.html#prod-Atom">Atom</a><emu-mods><emu-params>[?UnicodeMode, ?UnicodeSetsMode, ?NamedCaptureGroups]</emu-params></emu-mods></emu-nt>
|
||
</emu-rhs>
|
||
<emu-rhs a="b5sq7xbb" id="prod-FwIStaHw">
|
||
<emu-nt params="?UnicodeMode, ?UnicodeSetsMode, ?NamedCaptureGroups" id="_ref_23946"><a href="text-processing.html#prod-Atom">Atom</a><emu-mods><emu-params>[?UnicodeMode, ?UnicodeSetsMode, ?NamedCaptureGroups]</emu-params></emu-mods></emu-nt>
|
||
<emu-nt id="_ref_23947"><a href="text-processing.html#prod-Quantifier">Quantifier</a></emu-nt>
|
||
</emu-rhs>
|
||
</emu-production>
|
||
<emu-production name="Assertion" params="UnicodeMode, UnicodeSetsMode, NamedCaptureGroups" type="lexical" id="prod-Assertion">
|
||
<emu-nt params="UnicodeMode, UnicodeSetsMode, NamedCaptureGroups"><a href="text-processing.html#prod-Assertion">Assertion</a><emu-mods><emu-params>[UnicodeMode, UnicodeSetsMode, NamedCaptureGroups]</emu-params></emu-mods></emu-nt> <emu-geq>::</emu-geq> <emu-rhs a="5yeieuod" id="prod--UK1vL-o">
|
||
<emu-t>^</emu-t>
|
||
</emu-rhs>
|
||
<emu-rhs a="emlmkqfm" id="prod-2McWu3FN">
|
||
<emu-t>$</emu-t>
|
||
</emu-rhs>
|
||
<emu-rhs a="axxsqknu" id="prod-YjbmHFUC">
|
||
<emu-t>\b</emu-t>
|
||
</emu-rhs>
|
||
<emu-rhs a="lnx_opbv" id="prod-gShCnTuF">
|
||
<emu-t>\B</emu-t>
|
||
</emu-rhs>
|
||
<emu-rhs a="hftgdk-r" id="prod-xKW9miPx">
|
||
<emu-t>(?=</emu-t>
|
||
<emu-nt params="?UnicodeMode, ?UnicodeSetsMode, ?NamedCaptureGroups" id="_ref_23948"><a href="text-processing.html#prod-Disjunction">Disjunction</a><emu-mods><emu-params>[?UnicodeMode, ?UnicodeSetsMode, ?NamedCaptureGroups]</emu-params></emu-mods></emu-nt>
|
||
<emu-t>)</emu-t>
|
||
</emu-rhs>
|
||
<emu-rhs a="6jphpcfp" id="prod-vTbSFHd1">
|
||
<emu-t>(?!</emu-t>
|
||
<emu-nt params="?UnicodeMode, ?UnicodeSetsMode, ?NamedCaptureGroups" id="_ref_23949"><a href="text-processing.html#prod-Disjunction">Disjunction</a><emu-mods><emu-params>[?UnicodeMode, ?UnicodeSetsMode, ?NamedCaptureGroups]</emu-params></emu-mods></emu-nt>
|
||
<emu-t>)</emu-t>
|
||
</emu-rhs>
|
||
<emu-rhs a="mvzyfsps" id="prod-Xp1qSNTG">
|
||
<emu-t>(?<=</emu-t>
|
||
<emu-nt params="?UnicodeMode, ?UnicodeSetsMode, ?NamedCaptureGroups" id="_ref_23950"><a href="text-processing.html#prod-Disjunction">Disjunction</a><emu-mods><emu-params>[?UnicodeMode, ?UnicodeSetsMode, ?NamedCaptureGroups]</emu-params></emu-mods></emu-nt>
|
||
<emu-t>)</emu-t>
|
||
</emu-rhs>
|
||
<emu-rhs a="i9jfixsb" id="prod-UtOyozI6">
|
||
<emu-t>(?<!</emu-t>
|
||
<emu-nt params="?UnicodeMode, ?UnicodeSetsMode, ?NamedCaptureGroups" id="_ref_23951"><a href="text-processing.html#prod-Disjunction">Disjunction</a><emu-mods><emu-params>[?UnicodeMode, ?UnicodeSetsMode, ?NamedCaptureGroups]</emu-params></emu-mods></emu-nt>
|
||
<emu-t>)</emu-t>
|
||
</emu-rhs>
|
||
</emu-production>
|
||
<emu-production name="Quantifier" type="lexical" id="prod-Quantifier">
|
||
<emu-nt><a href="text-processing.html#prod-Quantifier">Quantifier</a></emu-nt> <emu-geq>::</emu-geq> <emu-rhs a="dlini2nj" id="prod-tUDOOFuV">
|
||
<emu-nt id="_ref_23952"><a href="text-processing.html#prod-QuantifierPrefix">QuantifierPrefix</a></emu-nt>
|
||
</emu-rhs>
|
||
<emu-rhs a="cwtuervy" id="prod-GZavMceB">
|
||
<emu-nt id="_ref_23953"><a href="text-processing.html#prod-QuantifierPrefix">QuantifierPrefix</a></emu-nt>
|
||
<emu-t>?</emu-t>
|
||
</emu-rhs>
|
||
</emu-production>
|
||
<emu-production name="QuantifierPrefix" type="lexical" id="prod-QuantifierPrefix">
|
||
<emu-nt><a href="text-processing.html#prod-QuantifierPrefix">QuantifierPrefix</a></emu-nt> <emu-geq>::</emu-geq> <emu-rhs a="sb5ztei-" id="prod-vLv9dnb5">
|
||
<emu-t>*</emu-t>
|
||
</emu-rhs>
|
||
<emu-rhs a="4dclbrwl" id="prod-UgDebVXB">
|
||
<emu-t>+</emu-t>
|
||
</emu-rhs>
|
||
<emu-rhs a="iy1xym7h" id="prod-N4RBWkLM">
|
||
<emu-t>?</emu-t>
|
||
</emu-rhs>
|
||
<emu-rhs a="qn2ibvok" id="prod-kgxh0ghk">
|
||
<emu-t>{</emu-t>
|
||
<emu-nt params="~Sep" id="_ref_23954"><a href="ecmascript-language-lexical-grammar.html#prod-DecimalDigits">DecimalDigits</a><emu-mods><emu-params>[~Sep]</emu-params></emu-mods></emu-nt>
|
||
<emu-t>}</emu-t>
|
||
</emu-rhs>
|
||
<emu-rhs a="tij_jhmn" id="prod-FM-pL4Gj">
|
||
<emu-t>{</emu-t>
|
||
<emu-nt params="~Sep" id="_ref_23955"><a href="ecmascript-language-lexical-grammar.html#prod-DecimalDigits">DecimalDigits</a><emu-mods><emu-params>[~Sep]</emu-params></emu-mods></emu-nt>
|
||
<emu-t>,}</emu-t>
|
||
</emu-rhs>
|
||
<emu-rhs a="bthfi5pb" id="prod-bLgfIwO4">
|
||
<emu-t>{</emu-t>
|
||
<emu-nt params="~Sep" id="_ref_23956"><a href="ecmascript-language-lexical-grammar.html#prod-DecimalDigits">DecimalDigits</a><emu-mods><emu-params>[~Sep]</emu-params></emu-mods></emu-nt>
|
||
<emu-t>,</emu-t>
|
||
<emu-nt params="~Sep" id="_ref_23957"><a href="ecmascript-language-lexical-grammar.html#prod-DecimalDigits">DecimalDigits</a><emu-mods><emu-params>[~Sep]</emu-params></emu-mods></emu-nt>
|
||
<emu-t>}</emu-t>
|
||
</emu-rhs>
|
||
</emu-production>
|
||
<emu-production name="Atom" params="UnicodeMode, UnicodeSetsMode, NamedCaptureGroups" type="lexical" id="prod-Atom">
|
||
<emu-nt params="UnicodeMode, UnicodeSetsMode, NamedCaptureGroups"><a href="text-processing.html#prod-Atom">Atom</a><emu-mods><emu-params>[UnicodeMode, UnicodeSetsMode, NamedCaptureGroups]</emu-params></emu-mods></emu-nt> <emu-geq>::</emu-geq> <emu-rhs a="vv9sxhyc" id="prod-hYVkAeML">
|
||
<emu-nt id="_ref_23958"><a href="text-processing.html#prod-PatternCharacter">PatternCharacter</a></emu-nt>
|
||
</emu-rhs>
|
||
<emu-rhs a="lljkc4zd" id="prod-6UeGTTDU">
|
||
<emu-t>.</emu-t>
|
||
</emu-rhs>
|
||
<emu-rhs a="jhiwossb">
|
||
<emu-t>\</emu-t>
|
||
<emu-nt params="?UnicodeMode, ?NamedCaptureGroups" id="_ref_23959"><a href="text-processing.html#prod-AtomEscape">AtomEscape</a><emu-mods><emu-params>[?UnicodeMode, ?NamedCaptureGroups]</emu-params></emu-mods></emu-nt>
|
||
</emu-rhs>
|
||
<emu-rhs a="00eq8hij" id="prod-gdPiaYp4">
|
||
<emu-nt params="?UnicodeMode, ?UnicodeSetsMode" id="_ref_23960"><a href="text-processing.html#prod-CharacterClass">CharacterClass</a><emu-mods><emu-params>[?UnicodeMode, ?UnicodeSetsMode]</emu-params></emu-mods></emu-nt>
|
||
</emu-rhs>
|
||
<emu-rhs a="kqlb6ij4" id="prod-XC-6aJgH">
|
||
<emu-t>(</emu-t>
|
||
<emu-nt params="?UnicodeMode" optional="" id="_ref_23961"><a href="text-processing.html#prod-GroupSpecifier">GroupSpecifier</a><emu-mods><emu-params>[?UnicodeMode]</emu-params><emu-opt>opt</emu-opt></emu-mods></emu-nt>
|
||
<emu-nt params="?UnicodeMode, ?UnicodeSetsMode, ?NamedCaptureGroups" id="_ref_23962"><a href="text-processing.html#prod-Disjunction">Disjunction</a><emu-mods><emu-params>[?UnicodeMode, ?UnicodeSetsMode, ?NamedCaptureGroups]</emu-params></emu-mods></emu-nt>
|
||
<emu-t>)</emu-t>
|
||
</emu-rhs>
|
||
<emu-rhs a="veose2ut" id="prod-pz1sJFAi">
|
||
<emu-t>(?</emu-t>
|
||
<emu-nt id="_ref_23963"><a href="text-processing.html#prod-RegularExpressionModifiers">RegularExpressionModifiers</a></emu-nt>
|
||
<emu-t>:</emu-t>
|
||
<emu-nt params="?UnicodeMode, ?UnicodeSetsMode, ?NamedCaptureGroups" id="_ref_23964"><a href="text-processing.html#prod-Disjunction">Disjunction</a><emu-mods><emu-params>[?UnicodeMode, ?UnicodeSetsMode, ?NamedCaptureGroups]</emu-params></emu-mods></emu-nt>
|
||
<emu-t>)</emu-t>
|
||
</emu-rhs>
|
||
<emu-rhs a="2rhyberh" id="prod-kBLGeTWR">
|
||
<emu-t>(?</emu-t>
|
||
<emu-nt id="_ref_23965"><a href="text-processing.html#prod-RegularExpressionModifiers">RegularExpressionModifiers</a></emu-nt>
|
||
<emu-t>-</emu-t>
|
||
<emu-nt id="_ref_23966"><a href="text-processing.html#prod-RegularExpressionModifiers">RegularExpressionModifiers</a></emu-nt>
|
||
<emu-t>:</emu-t>
|
||
<emu-nt params="?UnicodeMode, ?UnicodeSetsMode, ?NamedCaptureGroups" id="_ref_23967"><a href="text-processing.html#prod-Disjunction">Disjunction</a><emu-mods><emu-params>[?UnicodeMode, ?UnicodeSetsMode, ?NamedCaptureGroups]</emu-params></emu-mods></emu-nt>
|
||
<emu-t>)</emu-t>
|
||
</emu-rhs>
|
||
</emu-production>
|
||
<emu-production name="RegularExpressionModifiers" type="lexical" id="prod-RegularExpressionModifiers">
|
||
<emu-nt><a href="text-processing.html#prod-RegularExpressionModifiers">RegularExpressionModifiers</a></emu-nt> <emu-geq>::</emu-geq> <emu-rhs a="n7nathbb">
|
||
<emu-gann>[empty]</emu-gann>
|
||
</emu-rhs>
|
||
<emu-rhs a="qehgnqhb">
|
||
<emu-nt id="_ref_23968"><a href="text-processing.html#prod-RegularExpressionModifiers">RegularExpressionModifiers</a></emu-nt>
|
||
<emu-nt id="_ref_23969"><a href="text-processing.html#prod-RegularExpressionModifier">RegularExpressionModifier</a></emu-nt>
|
||
</emu-rhs>
|
||
</emu-production>
|
||
<emu-production name="RegularExpressionModifier" type="lexical" oneof="" id="prod-RegularExpressionModifier">
|
||
<emu-nt><a href="text-processing.html#prod-RegularExpressionModifier">RegularExpressionModifier</a></emu-nt> <emu-geq>::</emu-geq> <emu-oneof>one of</emu-oneof> <emu-rhs><emu-t>i</emu-t> <emu-t>m</emu-t> <emu-t>s</emu-t></emu-rhs>
|
||
</emu-production>
|
||
<emu-production name="SyntaxCharacter" type="lexical" oneof="" id="prod-SyntaxCharacter">
|
||
<emu-nt><a href="text-processing.html#prod-SyntaxCharacter">SyntaxCharacter</a></emu-nt> <emu-geq>::</emu-geq> <emu-oneof>one of</emu-oneof> <emu-rhs><emu-t>^</emu-t> <emu-t>$</emu-t> <emu-t>\</emu-t> <emu-t>.</emu-t> <emu-t>*</emu-t> <emu-t>+</emu-t> <emu-t>?</emu-t> <emu-t>(</emu-t> <emu-t>)</emu-t> <emu-t>[</emu-t> <emu-t>]</emu-t> <emu-t>{</emu-t> <emu-t>}</emu-t> <emu-t>|</emu-t></emu-rhs>
|
||
</emu-production>
|
||
<emu-production name="PatternCharacter" type="lexical" id="prod-PatternCharacter">
|
||
<emu-nt><a href="text-processing.html#prod-PatternCharacter">PatternCharacter</a></emu-nt> <emu-geq>::</emu-geq> <emu-rhs a="uu1noe--">
|
||
<emu-nt id="_ref_23970"><a href="ecmascript-language-source-code.html#prod-SourceCharacter">SourceCharacter</a></emu-nt> <emu-gmod>but not <emu-nt id="_ref_23971"><a href="text-processing.html#prod-SyntaxCharacter">SyntaxCharacter</a></emu-nt></emu-gmod>
|
||
</emu-rhs>
|
||
</emu-production>
|
||
<emu-production name="AtomEscape" params="UnicodeMode, NamedCaptureGroups" type="lexical" id="prod-AtomEscape">
|
||
<emu-nt params="UnicodeMode, NamedCaptureGroups"><a href="text-processing.html#prod-AtomEscape">AtomEscape</a><emu-mods><emu-params>[UnicodeMode, NamedCaptureGroups]</emu-params></emu-mods></emu-nt> <emu-geq>::</emu-geq> <emu-rhs a="fr_5bnut" id="prod-2qcgA24q">
|
||
<emu-nt id="_ref_23972"><a href="text-processing.html#prod-DecimalEscape">DecimalEscape</a></emu-nt>
|
||
</emu-rhs>
|
||
<emu-rhs a="1dlni0cs" id="prod-QZtCcvYH">
|
||
<emu-nt params="?UnicodeMode" id="_ref_23973"><a href="text-processing.html#prod-CharacterClassEscape">CharacterClassEscape</a><emu-mods><emu-params>[?UnicodeMode]</emu-params></emu-mods></emu-nt>
|
||
</emu-rhs>
|
||
<emu-rhs a="i4ceewqb" id="prod-sBosbs9Q">
|
||
<emu-nt params="?UnicodeMode" id="_ref_23974"><a href="text-processing.html#prod-CharacterEscape">CharacterEscape</a><emu-mods><emu-params>[?UnicodeMode]</emu-params></emu-mods></emu-nt>
|
||
</emu-rhs>
|
||
<emu-rhs a="jsb3w65g" constraints="+NamedCaptureGroups" id="prod-YgRCIQFy"><emu-constraints>[+NamedCaptureGroups]</emu-constraints>
|
||
<emu-t>k</emu-t>
|
||
<emu-nt params="?UnicodeMode" id="_ref_23975"><a href="text-processing.html#prod-GroupName">GroupName</a><emu-mods><emu-params>[?UnicodeMode]</emu-params></emu-mods></emu-nt>
|
||
</emu-rhs>
|
||
</emu-production>
|
||
<emu-production name="CharacterEscape" params="UnicodeMode" type="lexical" id="prod-CharacterEscape">
|
||
<emu-nt params="UnicodeMode"><a href="text-processing.html#prod-CharacterEscape">CharacterEscape</a><emu-mods><emu-params>[UnicodeMode]</emu-params></emu-mods></emu-nt> <emu-geq>::</emu-geq> <emu-rhs a="-i5xcal8" id="prod-q4aq35sO">
|
||
<emu-nt id="_ref_23976"><a href="text-processing.html#prod-ControlEscape">ControlEscape</a></emu-nt>
|
||
</emu-rhs>
|
||
<emu-rhs a="lf4h7vn-" id="prod-lMmOF-9c">
|
||
<emu-t>c</emu-t>
|
||
<emu-nt id="_ref_23977"><a href="ecmascript-language-lexical-grammar.html#prod-AsciiLetter">AsciiLetter</a></emu-nt>
|
||
</emu-rhs>
|
||
<emu-rhs a="br2d94cy" id="prod-oPPhk0pZ">
|
||
<emu-t>0</emu-t>
|
||
<emu-gann>[lookahead ∉ <emu-nt id="_ref_23978"><a href="ecmascript-language-lexical-grammar.html#prod-DecimalDigit">DecimalDigit</a></emu-nt>]</emu-gann>
|
||
</emu-rhs>
|
||
<emu-rhs a="qacbhaps" id="prod-CrHLbIYs">
|
||
<emu-nt id="_ref_23979"><a href="ecmascript-language-lexical-grammar.html#prod-HexEscapeSequence">HexEscapeSequence</a></emu-nt>
|
||
</emu-rhs>
|
||
<emu-rhs a="swcse7so">
|
||
<emu-nt params="?UnicodeMode" id="_ref_23980"><a href="text-processing.html#prod-RegExpUnicodeEscapeSequence">RegExpUnicodeEscapeSequence</a><emu-mods><emu-params>[?UnicodeMode]</emu-params></emu-mods></emu-nt>
|
||
</emu-rhs>
|
||
<emu-rhs a="6_pkjcjw" id="prod-VtjEN4lt">
|
||
<emu-nt params="?UnicodeMode" id="_ref_23981"><a href="text-processing.html#prod-IdentityEscape">IdentityEscape</a><emu-mods><emu-params>[?UnicodeMode]</emu-params></emu-mods></emu-nt>
|
||
</emu-rhs>
|
||
</emu-production>
|
||
<emu-production name="ControlEscape" type="lexical" oneof="" id="prod-ControlEscape">
|
||
<emu-nt><a href="text-processing.html#prod-ControlEscape">ControlEscape</a></emu-nt> <emu-geq>::</emu-geq> <emu-oneof>one of</emu-oneof> <emu-rhs><emu-t>f</emu-t> <emu-t>n</emu-t> <emu-t>r</emu-t> <emu-t>t</emu-t> <emu-t>v</emu-t></emu-rhs>
|
||
</emu-production>
|
||
<emu-production name="GroupSpecifier" params="UnicodeMode" type="lexical" id="prod-GroupSpecifier">
|
||
<emu-nt params="UnicodeMode"><a href="text-processing.html#prod-GroupSpecifier">GroupSpecifier</a><emu-mods><emu-params>[UnicodeMode]</emu-params></emu-mods></emu-nt> <emu-geq>::</emu-geq> <emu-rhs a="unyz_r7p">
|
||
<emu-t>?</emu-t>
|
||
<emu-nt params="?UnicodeMode" id="_ref_23982"><a href="text-processing.html#prod-GroupName">GroupName</a><emu-mods><emu-params>[?UnicodeMode]</emu-params></emu-mods></emu-nt>
|
||
</emu-rhs>
|
||
</emu-production>
|
||
<emu-production name="GroupName" params="UnicodeMode" type="lexical" id="prod-GroupName">
|
||
<emu-nt params="UnicodeMode"><a href="text-processing.html#prod-GroupName">GroupName</a><emu-mods><emu-params>[UnicodeMode]</emu-params></emu-mods></emu-nt> <emu-geq>::</emu-geq> <emu-rhs a="bbvxam1q" id="prod-CieYjAI6">
|
||
<emu-t><</emu-t>
|
||
<emu-nt params="?UnicodeMode" id="_ref_23983"><a href="text-processing.html#prod-RegExpIdentifierName">RegExpIdentifierName</a><emu-mods><emu-params>[?UnicodeMode]</emu-params></emu-mods></emu-nt>
|
||
<emu-t>></emu-t>
|
||
</emu-rhs>
|
||
</emu-production>
|
||
<emu-production name="RegExpIdentifierName" params="UnicodeMode" type="lexical" id="prod-RegExpIdentifierName">
|
||
<emu-nt params="UnicodeMode"><a href="text-processing.html#prod-RegExpIdentifierName">RegExpIdentifierName</a><emu-mods><emu-params>[UnicodeMode]</emu-params></emu-mods></emu-nt> <emu-geq>::</emu-geq> <emu-rhs a="epjtohg4" id="prod-UEFofPmM">
|
||
<emu-nt params="?UnicodeMode" id="_ref_23984"><a href="text-processing.html#prod-RegExpIdentifierStart">RegExpIdentifierStart</a><emu-mods><emu-params>[?UnicodeMode]</emu-params></emu-mods></emu-nt>
|
||
</emu-rhs>
|
||
<emu-rhs a="5ujdxycq" id="prod-Wlj6DCQi">
|
||
<emu-nt params="?UnicodeMode" id="_ref_23985"><a href="text-processing.html#prod-RegExpIdentifierName">RegExpIdentifierName</a><emu-mods><emu-params>[?UnicodeMode]</emu-params></emu-mods></emu-nt>
|
||
<emu-nt params="?UnicodeMode" id="_ref_23986"><a href="text-processing.html#prod-RegExpIdentifierPart">RegExpIdentifierPart</a><emu-mods><emu-params>[?UnicodeMode]</emu-params></emu-mods></emu-nt>
|
||
</emu-rhs>
|
||
</emu-production>
|
||
<emu-production name="RegExpIdentifierStart" params="UnicodeMode" type="lexical" id="prod-RegExpIdentifierStart">
|
||
<emu-nt params="UnicodeMode"><a href="text-processing.html#prod-RegExpIdentifierStart">RegExpIdentifierStart</a><emu-mods><emu-params>[UnicodeMode]</emu-params></emu-mods></emu-nt> <emu-geq>::</emu-geq> <emu-rhs a="scjzw6a_" id="prod-ChPpokvC">
|
||
<emu-nt id="_ref_23987"><a href="ecmascript-language-lexical-grammar.html#prod-IdentifierStartChar">IdentifierStartChar</a></emu-nt>
|
||
</emu-rhs>
|
||
<emu-rhs a="ho0qxsau" id="prod-gHtf4gFI">
|
||
<emu-t>\</emu-t>
|
||
<emu-nt params="+UnicodeMode" id="_ref_23988"><a href="text-processing.html#prod-RegExpUnicodeEscapeSequence">RegExpUnicodeEscapeSequence</a><emu-mods><emu-params>[+UnicodeMode]</emu-params></emu-mods></emu-nt>
|
||
</emu-rhs>
|
||
<emu-rhs a="fpn-h6zn" constraints="~UnicodeMode" id="prod-WBQHipLA"><emu-constraints>[~UnicodeMode]</emu-constraints>
|
||
<emu-nt id="_ref_23989"><a href="text-processing.html#prod-UnicodeLeadSurrogate">UnicodeLeadSurrogate</a></emu-nt>
|
||
<emu-nt id="_ref_23990"><a href="text-processing.html#prod-UnicodeTrailSurrogate">UnicodeTrailSurrogate</a></emu-nt>
|
||
</emu-rhs>
|
||
</emu-production>
|
||
<emu-production name="RegExpIdentifierPart" params="UnicodeMode" type="lexical" id="prod-RegExpIdentifierPart">
|
||
<emu-nt params="UnicodeMode"><a href="text-processing.html#prod-RegExpIdentifierPart">RegExpIdentifierPart</a><emu-mods><emu-params>[UnicodeMode]</emu-params></emu-mods></emu-nt> <emu-geq>::</emu-geq> <emu-rhs a="q3hdl-qt" id="prod-QEKJWJ5I">
|
||
<emu-nt id="_ref_23991"><a href="ecmascript-language-lexical-grammar.html#prod-IdentifierPartChar">IdentifierPartChar</a></emu-nt>
|
||
</emu-rhs>
|
||
<emu-rhs a="ho0qxsau" id="prod-tb_1J4i8">
|
||
<emu-t>\</emu-t>
|
||
<emu-nt params="+UnicodeMode" id="_ref_23992"><a href="text-processing.html#prod-RegExpUnicodeEscapeSequence">RegExpUnicodeEscapeSequence</a><emu-mods><emu-params>[+UnicodeMode]</emu-params></emu-mods></emu-nt>
|
||
</emu-rhs>
|
||
<emu-rhs a="fpn-h6zn" constraints="~UnicodeMode" id="prod-NsruFaTJ"><emu-constraints>[~UnicodeMode]</emu-constraints>
|
||
<emu-nt id="_ref_23993"><a href="text-processing.html#prod-UnicodeLeadSurrogate">UnicodeLeadSurrogate</a></emu-nt>
|
||
<emu-nt id="_ref_23994"><a href="text-processing.html#prod-UnicodeTrailSurrogate">UnicodeTrailSurrogate</a></emu-nt>
|
||
</emu-rhs>
|
||
</emu-production>
|
||
<emu-production name="RegExpUnicodeEscapeSequence" params="UnicodeMode" type="lexical" id="prod-RegExpUnicodeEscapeSequence">
|
||
<emu-nt params="UnicodeMode"><a href="text-processing.html#prod-RegExpUnicodeEscapeSequence">RegExpUnicodeEscapeSequence</a><emu-mods><emu-params>[UnicodeMode]</emu-params></emu-mods></emu-nt> <emu-geq>::</emu-geq> <emu-rhs a="waogc0qp" constraints="+UnicodeMode" id="prod-8GU45ufS"><emu-constraints>[+UnicodeMode]</emu-constraints>
|
||
<emu-t>u</emu-t>
|
||
<emu-nt id="_ref_23995"><a href="text-processing.html#prod-HexLeadSurrogate">HexLeadSurrogate</a></emu-nt>
|
||
<emu-t>\u</emu-t>
|
||
<emu-nt id="_ref_23996"><a href="text-processing.html#prod-HexTrailSurrogate">HexTrailSurrogate</a></emu-nt>
|
||
</emu-rhs>
|
||
<emu-rhs a="hhq0f7ab" constraints="+UnicodeMode"><emu-constraints>[+UnicodeMode]</emu-constraints>
|
||
<emu-t>u</emu-t>
|
||
<emu-nt id="_ref_23997"><a href="text-processing.html#prod-HexLeadSurrogate">HexLeadSurrogate</a></emu-nt>
|
||
</emu-rhs>
|
||
<emu-rhs a="k3exmx9t" constraints="+UnicodeMode"><emu-constraints>[+UnicodeMode]</emu-constraints>
|
||
<emu-t>u</emu-t>
|
||
<emu-nt id="_ref_23998"><a href="text-processing.html#prod-HexTrailSurrogate">HexTrailSurrogate</a></emu-nt>
|
||
</emu-rhs>
|
||
<emu-rhs a="gun22eck" constraints="+UnicodeMode"><emu-constraints>[+UnicodeMode]</emu-constraints>
|
||
<emu-t>u</emu-t>
|
||
<emu-nt id="_ref_23999"><a href="text-processing.html#prod-HexNonSurrogate">HexNonSurrogate</a></emu-nt>
|
||
</emu-rhs>
|
||
<emu-rhs a="k_zr1roh" constraints="~UnicodeMode" id="prod-5oXd8wzV"><emu-constraints>[~UnicodeMode]</emu-constraints>
|
||
<emu-t>u</emu-t>
|
||
<emu-nt id="_ref_24000"><a href="ecmascript-language-lexical-grammar.html#prod-Hex4Digits">Hex4Digits</a></emu-nt>
|
||
</emu-rhs>
|
||
<emu-rhs a="42_-y9-i" constraints="+UnicodeMode" id="prod-CzkVQCuc"><emu-constraints>[+UnicodeMode]</emu-constraints>
|
||
<emu-t>u{</emu-t>
|
||
<emu-nt id="_ref_24001"><a href="ecmascript-language-lexical-grammar.html#prod-CodePoint">CodePoint</a></emu-nt>
|
||
<emu-t>}</emu-t>
|
||
</emu-rhs>
|
||
</emu-production>
|
||
<emu-production name="UnicodeLeadSurrogate" type="lexical" id="prod-UnicodeLeadSurrogate">
|
||
<emu-nt><a href="text-processing.html#prod-UnicodeLeadSurrogate">UnicodeLeadSurrogate</a></emu-nt> <emu-geq>::</emu-geq> <emu-rhs a="qq83i09m">
|
||
<emu-gprose>any Unicode code point in the inclusive interval from U+D800 to U+DBFF</emu-gprose>
|
||
</emu-rhs>
|
||
</emu-production>
|
||
<emu-production name="UnicodeTrailSurrogate" type="lexical" id="prod-UnicodeTrailSurrogate">
|
||
<emu-nt><a href="text-processing.html#prod-UnicodeTrailSurrogate">UnicodeTrailSurrogate</a></emu-nt> <emu-geq>::</emu-geq> <emu-rhs a="ivnwxcbc">
|
||
<emu-gprose>any Unicode code point in the inclusive interval from U+DC00 to U+DFFF</emu-gprose>
|
||
</emu-rhs>
|
||
</emu-production>
|
||
</emu-grammar>
|
||
<p>Each <code>\u</code> <emu-nt id="_ref_24002"><a href="text-processing.html#prod-HexTrailSurrogate">HexTrailSurrogate</a></emu-nt> for which the choice of associated <code>u</code> <emu-nt id="_ref_24003"><a href="text-processing.html#prod-HexLeadSurrogate">HexLeadSurrogate</a></emu-nt> is ambiguous shall be associated with the nearest possible <code>u</code> <emu-nt id="_ref_24004"><a href="text-processing.html#prod-HexLeadSurrogate">HexLeadSurrogate</a></emu-nt> that would otherwise have no corresponding <code>\u</code> <emu-nt id="_ref_24005"><a href="text-processing.html#prod-HexTrailSurrogate">HexTrailSurrogate</a></emu-nt>.</p>
|
||
<emu-grammar type="definition"><emu-production name="HexLeadSurrogate" type="lexical" id="prod-HexLeadSurrogate">
|
||
<emu-nt><a href="text-processing.html#prod-HexLeadSurrogate">HexLeadSurrogate</a></emu-nt> <emu-geq>::</emu-geq> <emu-rhs a="cblftfpk" id="prod-AEZ_iyDC">
|
||
<emu-nt id="_ref_24006"><a href="ecmascript-language-lexical-grammar.html#prod-Hex4Digits">Hex4Digits</a></emu-nt>
|
||
<emu-gmod>but only if the MV of <emu-nt id="_ref_24007"><a href="ecmascript-language-lexical-grammar.html#prod-Hex4Digits">Hex4Digits</a></emu-nt> is in the <emu-xref href="#inclusive-interval" id="_ref_11627"><a href="notational-conventions.html#inclusive-interval">inclusive interval</a></emu-xref> from 0xD800 to 0xDBFF</emu-gmod>
|
||
</emu-rhs>
|
||
</emu-production>
|
||
<emu-production name="HexTrailSurrogate" type="lexical" id="prod-HexTrailSurrogate">
|
||
<emu-nt><a href="text-processing.html#prod-HexTrailSurrogate">HexTrailSurrogate</a></emu-nt> <emu-geq>::</emu-geq> <emu-rhs a="xh8lnnlz" id="prod-aZFqSbDx">
|
||
<emu-nt id="_ref_24008"><a href="ecmascript-language-lexical-grammar.html#prod-Hex4Digits">Hex4Digits</a></emu-nt>
|
||
<emu-gmod>but only if the MV of <emu-nt id="_ref_24009"><a href="ecmascript-language-lexical-grammar.html#prod-Hex4Digits">Hex4Digits</a></emu-nt> is in the <emu-xref href="#inclusive-interval" id="_ref_11628"><a href="notational-conventions.html#inclusive-interval">inclusive interval</a></emu-xref> from 0xDC00 to 0xDFFF</emu-gmod>
|
||
</emu-rhs>
|
||
</emu-production>
|
||
<emu-production name="HexNonSurrogate" type="lexical" id="prod-HexNonSurrogate">
|
||
<emu-nt><a href="text-processing.html#prod-HexNonSurrogate">HexNonSurrogate</a></emu-nt> <emu-geq>::</emu-geq> <emu-rhs a="dwn60mjo" id="prod-YFxZ-zB2">
|
||
<emu-nt id="_ref_24010"><a href="ecmascript-language-lexical-grammar.html#prod-Hex4Digits">Hex4Digits</a></emu-nt>
|
||
<emu-gmod>but only if the MV of <emu-nt id="_ref_24011"><a href="ecmascript-language-lexical-grammar.html#prod-Hex4Digits">Hex4Digits</a></emu-nt> is not in the <emu-xref href="#inclusive-interval" id="_ref_11629"><a href="notational-conventions.html#inclusive-interval">inclusive interval</a></emu-xref> from 0xD800 to 0xDFFF</emu-gmod>
|
||
</emu-rhs>
|
||
</emu-production>
|
||
<emu-production name="IdentityEscape" params="UnicodeMode" type="lexical" id="prod-IdentityEscape">
|
||
<emu-nt params="UnicodeMode"><a href="text-processing.html#prod-IdentityEscape">IdentityEscape</a><emu-mods><emu-params>[UnicodeMode]</emu-params></emu-mods></emu-nt> <emu-geq>::</emu-geq> <emu-rhs a="_sxoisew" constraints="+UnicodeMode"><emu-constraints>[+UnicodeMode]</emu-constraints>
|
||
<emu-nt id="_ref_24012"><a href="text-processing.html#prod-SyntaxCharacter">SyntaxCharacter</a></emu-nt>
|
||
</emu-rhs>
|
||
<emu-rhs a="iiubx3hh" constraints="+UnicodeMode"><emu-constraints>[+UnicodeMode]</emu-constraints>
|
||
<emu-t>/</emu-t>
|
||
</emu-rhs>
|
||
<emu-rhs a="kxdkcwd_" constraints="~UnicodeMode"><emu-constraints>[~UnicodeMode]</emu-constraints>
|
||
<emu-nt id="_ref_24013"><a href="ecmascript-language-source-code.html#prod-SourceCharacter">SourceCharacter</a></emu-nt> <emu-gmod>but not <emu-nt id="_ref_24014"><a href="ecmascript-language-lexical-grammar.html#prod-UnicodeIDContinue">UnicodeIDContinue</a></emu-nt></emu-gmod>
|
||
</emu-rhs>
|
||
</emu-production>
|
||
<emu-production name="DecimalEscape" type="lexical" id="prod-DecimalEscape">
|
||
<emu-nt><a href="text-processing.html#prod-DecimalEscape">DecimalEscape</a></emu-nt> <emu-geq>::</emu-geq> <emu-rhs a="1ajrj4io" id="prod-PUMw6WxS">
|
||
<emu-nt id="_ref_24015"><a href="ecmascript-language-lexical-grammar.html#prod-NonZeroDigit">NonZeroDigit</a></emu-nt>
|
||
<emu-nt params="~Sep" optional="" id="_ref_24016"><a href="ecmascript-language-lexical-grammar.html#prod-DecimalDigits">DecimalDigits</a><emu-mods><emu-params>[~Sep]</emu-params><emu-opt>opt</emu-opt></emu-mods></emu-nt>
|
||
<emu-gann>[lookahead ∉ <emu-nt id="_ref_24017"><a href="ecmascript-language-lexical-grammar.html#prod-DecimalDigit">DecimalDigit</a></emu-nt>]</emu-gann>
|
||
</emu-rhs>
|
||
</emu-production>
|
||
<emu-production name="CharacterClassEscape" params="UnicodeMode" type="lexical" id="prod-CharacterClassEscape">
|
||
<emu-nt params="UnicodeMode"><a href="text-processing.html#prod-CharacterClassEscape">CharacterClassEscape</a><emu-mods><emu-params>[UnicodeMode]</emu-params></emu-mods></emu-nt> <emu-geq>::</emu-geq> <emu-rhs a="8pmnkw2i" id="prod-SeTTaRwS">
|
||
<emu-t>d</emu-t>
|
||
</emu-rhs>
|
||
<emu-rhs a="kzsugx0d" id="prod-JQe22hGV">
|
||
<emu-t>D</emu-t>
|
||
</emu-rhs>
|
||
<emu-rhs a="w5xsbsk3" id="prod-Ba3BrqMI">
|
||
<emu-t>s</emu-t>
|
||
</emu-rhs>
|
||
<emu-rhs a="avlpsekd" id="prod-mC3Wqo02">
|
||
<emu-t>S</emu-t>
|
||
</emu-rhs>
|
||
<emu-rhs a="lytism1a" id="prod-uRZ9YD5P">
|
||
<emu-t>w</emu-t>
|
||
</emu-rhs>
|
||
<emu-rhs a="rhxouzu-" id="prod-tSKKQe8i">
|
||
<emu-t>W</emu-t>
|
||
</emu-rhs>
|
||
<emu-rhs a="qowxggfi" constraints="+UnicodeMode" id="prod-5iubKlkQ"><emu-constraints>[+UnicodeMode]</emu-constraints>
|
||
<emu-t>p{</emu-t>
|
||
<emu-nt id="_ref_24018"><a href="text-processing.html#prod-UnicodePropertyValueExpression">UnicodePropertyValueExpression</a></emu-nt>
|
||
<emu-t>}</emu-t>
|
||
</emu-rhs>
|
||
<emu-rhs a="ufkccifh" constraints="+UnicodeMode" id="prod-LRNY7pYO"><emu-constraints>[+UnicodeMode]</emu-constraints>
|
||
<emu-t>P{</emu-t>
|
||
<emu-nt id="_ref_24019"><a href="text-processing.html#prod-UnicodePropertyValueExpression">UnicodePropertyValueExpression</a></emu-nt>
|
||
<emu-t>}</emu-t>
|
||
</emu-rhs>
|
||
</emu-production>
|
||
<emu-production name="UnicodePropertyValueExpression" type="lexical" id="prod-UnicodePropertyValueExpression">
|
||
<emu-nt><a href="text-processing.html#prod-UnicodePropertyValueExpression">UnicodePropertyValueExpression</a></emu-nt> <emu-geq>::</emu-geq> <emu-rhs a="sr3kbwzj" id="prod-wlk0gl-x">
|
||
<emu-nt id="_ref_24020"><a href="text-processing.html#prod-UnicodePropertyName">UnicodePropertyName</a></emu-nt>
|
||
<emu-t>=</emu-t>
|
||
<emu-nt id="_ref_24021"><a href="text-processing.html#prod-UnicodePropertyValue">UnicodePropertyValue</a></emu-nt>
|
||
</emu-rhs>
|
||
<emu-rhs a="jdlbklv9" id="prod-jMQ5xe2C">
|
||
<emu-nt id="_ref_24022"><a href="text-processing.html#prod-LoneUnicodePropertyNameOrValue">LoneUnicodePropertyNameOrValue</a></emu-nt>
|
||
</emu-rhs>
|
||
</emu-production>
|
||
<emu-production name="UnicodePropertyName" type="lexical" id="prod-UnicodePropertyName">
|
||
<emu-nt><a href="text-processing.html#prod-UnicodePropertyName">UnicodePropertyName</a></emu-nt> <emu-geq>::</emu-geq> <emu-rhs a="wmjhn5yf">
|
||
<emu-nt id="_ref_24023"><a href="text-processing.html#prod-UnicodePropertyNameCharacters">UnicodePropertyNameCharacters</a></emu-nt>
|
||
</emu-rhs>
|
||
</emu-production>
|
||
<emu-production name="UnicodePropertyNameCharacters" type="lexical" id="prod-UnicodePropertyNameCharacters">
|
||
<emu-nt><a href="text-processing.html#prod-UnicodePropertyNameCharacters">UnicodePropertyNameCharacters</a></emu-nt> <emu-geq>::</emu-geq> <emu-rhs a="wsr_rirg">
|
||
<emu-nt id="_ref_24024"><a href="text-processing.html#prod-UnicodePropertyNameCharacter">UnicodePropertyNameCharacter</a></emu-nt>
|
||
<emu-nt optional="" id="_ref_24025"><a href="text-processing.html#prod-UnicodePropertyNameCharacters">UnicodePropertyNameCharacters</a><emu-mods><emu-opt>opt</emu-opt></emu-mods></emu-nt>
|
||
</emu-rhs>
|
||
</emu-production>
|
||
<emu-production name="UnicodePropertyValue" type="lexical" id="prod-UnicodePropertyValue">
|
||
<emu-nt><a href="text-processing.html#prod-UnicodePropertyValue">UnicodePropertyValue</a></emu-nt> <emu-geq>::</emu-geq> <emu-rhs a="umqrcndj">
|
||
<emu-nt id="_ref_24026"><a href="text-processing.html#prod-UnicodePropertyValueCharacters">UnicodePropertyValueCharacters</a></emu-nt>
|
||
</emu-rhs>
|
||
</emu-production>
|
||
<emu-production name="LoneUnicodePropertyNameOrValue" type="lexical" id="prod-LoneUnicodePropertyNameOrValue">
|
||
<emu-nt><a href="text-processing.html#prod-LoneUnicodePropertyNameOrValue">LoneUnicodePropertyNameOrValue</a></emu-nt> <emu-geq>::</emu-geq> <emu-rhs a="umqrcndj">
|
||
<emu-nt id="_ref_24027"><a href="text-processing.html#prod-UnicodePropertyValueCharacters">UnicodePropertyValueCharacters</a></emu-nt>
|
||
</emu-rhs>
|
||
</emu-production>
|
||
<emu-production name="UnicodePropertyValueCharacters" type="lexical" id="prod-UnicodePropertyValueCharacters">
|
||
<emu-nt><a href="text-processing.html#prod-UnicodePropertyValueCharacters">UnicodePropertyValueCharacters</a></emu-nt> <emu-geq>::</emu-geq> <emu-rhs a="wickoffg">
|
||
<emu-nt id="_ref_24028"><a href="text-processing.html#prod-UnicodePropertyValueCharacter">UnicodePropertyValueCharacter</a></emu-nt>
|
||
<emu-nt optional="" id="_ref_24029"><a href="text-processing.html#prod-UnicodePropertyValueCharacters">UnicodePropertyValueCharacters</a><emu-mods><emu-opt>opt</emu-opt></emu-mods></emu-nt>
|
||
</emu-rhs>
|
||
</emu-production>
|
||
<emu-production name="UnicodePropertyValueCharacter" type="lexical" id="prod-UnicodePropertyValueCharacter">
|
||
<emu-nt><a href="text-processing.html#prod-UnicodePropertyValueCharacter">UnicodePropertyValueCharacter</a></emu-nt> <emu-geq>::</emu-geq> <emu-rhs a="uxjuzani">
|
||
<emu-nt id="_ref_24030"><a href="text-processing.html#prod-UnicodePropertyNameCharacter">UnicodePropertyNameCharacter</a></emu-nt>
|
||
</emu-rhs>
|
||
<emu-rhs a="s4me4hlz">
|
||
<emu-nt id="_ref_24031"><a href="ecmascript-language-lexical-grammar.html#prod-DecimalDigit">DecimalDigit</a></emu-nt>
|
||
</emu-rhs>
|
||
</emu-production>
|
||
<emu-production name="UnicodePropertyNameCharacter" type="lexical" id="prod-UnicodePropertyNameCharacter">
|
||
<emu-nt><a href="text-processing.html#prod-UnicodePropertyNameCharacter">UnicodePropertyNameCharacter</a></emu-nt> <emu-geq>::</emu-geq> <emu-rhs a="7q8tumk4">
|
||
<emu-nt id="_ref_24032"><a href="ecmascript-language-lexical-grammar.html#prod-AsciiLetter">AsciiLetter</a></emu-nt>
|
||
</emu-rhs>
|
||
<emu-rhs a="b1zllonv">
|
||
<emu-t>_</emu-t>
|
||
</emu-rhs>
|
||
</emu-production>
|
||
<emu-production name="CharacterClass" params="UnicodeMode, UnicodeSetsMode" type="lexical" id="prod-CharacterClass">
|
||
<emu-nt params="UnicodeMode, UnicodeSetsMode"><a href="text-processing.html#prod-CharacterClass">CharacterClass</a><emu-mods><emu-params>[UnicodeMode, UnicodeSetsMode]</emu-params></emu-mods></emu-nt> <emu-geq>::</emu-geq> <emu-rhs a="7jlltzv-" id="prod-XeZ8wReK">
|
||
<emu-t>[</emu-t>
|
||
<emu-gann>[lookahead ≠ <emu-t>^</emu-t>]</emu-gann>
|
||
<emu-nt params="?UnicodeMode, ?UnicodeSetsMode" id="_ref_24033"><a href="text-processing.html#prod-ClassContents">ClassContents</a><emu-mods><emu-params>[?UnicodeMode, ?UnicodeSetsMode]</emu-params></emu-mods></emu-nt>
|
||
<emu-t>]</emu-t>
|
||
</emu-rhs>
|
||
<emu-rhs a="8cldojko" id="prod-BR9Nw5Gp">
|
||
<emu-t>[^</emu-t>
|
||
<emu-nt params="?UnicodeMode, ?UnicodeSetsMode" id="_ref_24034"><a href="text-processing.html#prod-ClassContents">ClassContents</a><emu-mods><emu-params>[?UnicodeMode, ?UnicodeSetsMode]</emu-params></emu-mods></emu-nt>
|
||
<emu-t>]</emu-t>
|
||
</emu-rhs>
|
||
</emu-production>
|
||
<emu-production name="ClassContents" params="UnicodeMode, UnicodeSetsMode" type="lexical" id="prod-ClassContents">
|
||
<emu-nt params="UnicodeMode, UnicodeSetsMode"><a href="text-processing.html#prod-ClassContents">ClassContents</a><emu-mods><emu-params>[UnicodeMode, UnicodeSetsMode]</emu-params></emu-mods></emu-nt> <emu-geq>::</emu-geq> <emu-rhs a="n7nathbb" id="prod-7oNDq70_">
|
||
<emu-gann>[empty]</emu-gann>
|
||
</emu-rhs>
|
||
<emu-rhs a="n1dm9hk1" constraints="~UnicodeSetsMode" id="prod-Qe2Av6B8"><emu-constraints>[~UnicodeSetsMode]</emu-constraints>
|
||
<emu-nt params="?UnicodeMode" id="_ref_24035"><a href="text-processing.html#prod-NonemptyClassRanges">NonemptyClassRanges</a><emu-mods><emu-params>[?UnicodeMode]</emu-params></emu-mods></emu-nt>
|
||
</emu-rhs>
|
||
<emu-rhs a="mn83sbuj" constraints="+UnicodeSetsMode"><emu-constraints>[+UnicodeSetsMode]</emu-constraints>
|
||
<emu-nt id="_ref_24036"><a href="text-processing.html#prod-ClassSetExpression">ClassSetExpression</a></emu-nt>
|
||
</emu-rhs>
|
||
</emu-production>
|
||
<emu-production name="NonemptyClassRanges" params="UnicodeMode" type="lexical" id="prod-NonemptyClassRanges">
|
||
<emu-nt params="UnicodeMode"><a href="text-processing.html#prod-NonemptyClassRanges">NonemptyClassRanges</a><emu-mods><emu-params>[UnicodeMode]</emu-params></emu-mods></emu-nt> <emu-geq>::</emu-geq> <emu-rhs a="p14hei32">
|
||
<emu-nt params="?UnicodeMode" id="_ref_24037"><a href="text-processing.html#prod-ClassAtom">ClassAtom</a><emu-mods><emu-params>[?UnicodeMode]</emu-params></emu-mods></emu-nt>
|
||
</emu-rhs>
|
||
<emu-rhs a="-_prw338" id="prod-8-K7AdXe">
|
||
<emu-nt params="?UnicodeMode" id="_ref_24038"><a href="text-processing.html#prod-ClassAtom">ClassAtom</a><emu-mods><emu-params>[?UnicodeMode]</emu-params></emu-mods></emu-nt>
|
||
<emu-nt params="?UnicodeMode" id="_ref_24039"><a href="text-processing.html#prod-NonemptyClassRangesNoDash">NonemptyClassRangesNoDash</a><emu-mods><emu-params>[?UnicodeMode]</emu-params></emu-mods></emu-nt>
|
||
</emu-rhs>
|
||
<emu-rhs a="1ikw0jm6" id="prod--cKKVMsq">
|
||
<emu-nt params="?UnicodeMode" id="_ref_24040"><a href="text-processing.html#prod-ClassAtom">ClassAtom</a><emu-mods><emu-params>[?UnicodeMode]</emu-params></emu-mods></emu-nt>
|
||
<emu-t>-</emu-t>
|
||
<emu-nt params="?UnicodeMode" id="_ref_24041"><a href="text-processing.html#prod-ClassAtom">ClassAtom</a><emu-mods><emu-params>[?UnicodeMode]</emu-params></emu-mods></emu-nt>
|
||
<emu-nt params="?UnicodeMode, ~UnicodeSetsMode" id="_ref_24042"><a href="text-processing.html#prod-ClassContents">ClassContents</a><emu-mods><emu-params>[?UnicodeMode, ~UnicodeSetsMode]</emu-params></emu-mods></emu-nt>
|
||
</emu-rhs>
|
||
</emu-production>
|
||
<emu-production name="NonemptyClassRangesNoDash" params="UnicodeMode" type="lexical" id="prod-NonemptyClassRangesNoDash">
|
||
<emu-nt params="UnicodeMode"><a href="text-processing.html#prod-NonemptyClassRangesNoDash">NonemptyClassRangesNoDash</a><emu-mods><emu-params>[UnicodeMode]</emu-params></emu-mods></emu-nt> <emu-geq>::</emu-geq> <emu-rhs a="p14hei32">
|
||
<emu-nt params="?UnicodeMode" id="_ref_24043"><a href="text-processing.html#prod-ClassAtom">ClassAtom</a><emu-mods><emu-params>[?UnicodeMode]</emu-params></emu-mods></emu-nt>
|
||
</emu-rhs>
|
||
<emu-rhs a="tfcxdhcb" id="prod-MjoVem1x">
|
||
<emu-nt params="?UnicodeMode" id="_ref_24044"><a href="text-processing.html#prod-ClassAtomNoDash">ClassAtomNoDash</a><emu-mods><emu-params>[?UnicodeMode]</emu-params></emu-mods></emu-nt>
|
||
<emu-nt params="?UnicodeMode" id="_ref_24045"><a href="text-processing.html#prod-NonemptyClassRangesNoDash">NonemptyClassRangesNoDash</a><emu-mods><emu-params>[?UnicodeMode]</emu-params></emu-mods></emu-nt>
|
||
</emu-rhs>
|
||
<emu-rhs a="boblwo2h" id="prod-AN4eyFTZ">
|
||
<emu-nt params="?UnicodeMode" id="_ref_24046"><a href="text-processing.html#prod-ClassAtomNoDash">ClassAtomNoDash</a><emu-mods><emu-params>[?UnicodeMode]</emu-params></emu-mods></emu-nt>
|
||
<emu-t>-</emu-t>
|
||
<emu-nt params="?UnicodeMode" id="_ref_24047"><a href="text-processing.html#prod-ClassAtom">ClassAtom</a><emu-mods><emu-params>[?UnicodeMode]</emu-params></emu-mods></emu-nt>
|
||
<emu-nt params="?UnicodeMode, ~UnicodeSetsMode" id="_ref_24048"><a href="text-processing.html#prod-ClassContents">ClassContents</a><emu-mods><emu-params>[?UnicodeMode, ~UnicodeSetsMode]</emu-params></emu-mods></emu-nt>
|
||
</emu-rhs>
|
||
</emu-production>
|
||
<emu-production name="ClassAtom" params="UnicodeMode" type="lexical" id="prod-ClassAtom">
|
||
<emu-nt params="UnicodeMode"><a href="text-processing.html#prod-ClassAtom">ClassAtom</a><emu-mods><emu-params>[UnicodeMode]</emu-params></emu-mods></emu-nt> <emu-geq>::</emu-geq> <emu-rhs a="byslh4l8" id="prod-ee-3CYw6">
|
||
<emu-t>-</emu-t>
|
||
</emu-rhs>
|
||
<emu-rhs a="nglojpbu">
|
||
<emu-nt params="?UnicodeMode" id="_ref_24049"><a href="text-processing.html#prod-ClassAtomNoDash">ClassAtomNoDash</a><emu-mods><emu-params>[?UnicodeMode]</emu-params></emu-mods></emu-nt>
|
||
</emu-rhs>
|
||
</emu-production>
|
||
<emu-production name="ClassAtomNoDash" params="UnicodeMode" type="lexical" id="prod-ClassAtomNoDash">
|
||
<emu-nt params="UnicodeMode"><a href="text-processing.html#prod-ClassAtomNoDash">ClassAtomNoDash</a><emu-mods><emu-params>[UnicodeMode]</emu-params></emu-mods></emu-nt> <emu-geq>::</emu-geq> <emu-rhs a="7n5ukjeb" id="prod-DSKNclKY">
|
||
<emu-nt id="_ref_24050"><a href="ecmascript-language-source-code.html#prod-SourceCharacter">SourceCharacter</a></emu-nt> <emu-gmod>but not one of <emu-t>\</emu-t> or <emu-t>]</emu-t> or <emu-t>-</emu-t></emu-gmod>
|
||
</emu-rhs>
|
||
<emu-rhs a="8qgkzxcd">
|
||
<emu-t>\</emu-t>
|
||
<emu-nt params="?UnicodeMode" id="_ref_24051"><a href="text-processing.html#prod-ClassEscape">ClassEscape</a><emu-mods><emu-params>[?UnicodeMode]</emu-params></emu-mods></emu-nt>
|
||
</emu-rhs>
|
||
</emu-production>
|
||
<emu-production name="ClassEscape" params="UnicodeMode" type="lexical" id="prod-ClassEscape">
|
||
<emu-nt params="UnicodeMode"><a href="text-processing.html#prod-ClassEscape">ClassEscape</a><emu-mods><emu-params>[UnicodeMode]</emu-params></emu-mods></emu-nt> <emu-geq>::</emu-geq> <emu-rhs a="ayxoiyyq" id="prod-MZvj9Dzw">
|
||
<emu-t>b</emu-t>
|
||
</emu-rhs>
|
||
<emu-rhs a="7_g4l0lw" constraints="+UnicodeMode" id="prod-A6KLgGNK"><emu-constraints>[+UnicodeMode]</emu-constraints>
|
||
<emu-t>-</emu-t>
|
||
</emu-rhs>
|
||
<emu-rhs a="1dlni0cs" id="prod-pRiuVk3t">
|
||
<emu-nt params="?UnicodeMode" id="_ref_24052"><a href="text-processing.html#prod-CharacterClassEscape">CharacterClassEscape</a><emu-mods><emu-params>[?UnicodeMode]</emu-params></emu-mods></emu-nt>
|
||
</emu-rhs>
|
||
<emu-rhs a="i4ceewqb" id="prod-NKSKjwBB">
|
||
<emu-nt params="?UnicodeMode" id="_ref_24053"><a href="text-processing.html#prod-CharacterEscape">CharacterEscape</a><emu-mods><emu-params>[?UnicodeMode]</emu-params></emu-mods></emu-nt>
|
||
</emu-rhs>
|
||
</emu-production>
|
||
<emu-production name="ClassSetExpression" type="lexical" id="prod-ClassSetExpression">
|
||
<emu-nt><a href="text-processing.html#prod-ClassSetExpression">ClassSetExpression</a></emu-nt> <emu-geq>::</emu-geq> <emu-rhs a="3kf_tbjz">
|
||
<emu-nt id="_ref_24054"><a href="text-processing.html#prod-ClassUnion">ClassUnion</a></emu-nt>
|
||
</emu-rhs>
|
||
<emu-rhs a="iwshmigm">
|
||
<emu-nt id="_ref_24055"><a href="text-processing.html#prod-ClassIntersection">ClassIntersection</a></emu-nt>
|
||
</emu-rhs>
|
||
<emu-rhs a="xyhgeqif">
|
||
<emu-nt id="_ref_24056"><a href="text-processing.html#prod-ClassSubtraction">ClassSubtraction</a></emu-nt>
|
||
</emu-rhs>
|
||
</emu-production>
|
||
<emu-production name="ClassUnion" type="lexical" id="prod-ClassUnion">
|
||
<emu-nt><a href="text-processing.html#prod-ClassUnion">ClassUnion</a></emu-nt> <emu-geq>::</emu-geq> <emu-rhs a="lvavyv54" id="prod-g_C-vqXS">
|
||
<emu-nt id="_ref_24057"><a href="text-processing.html#prod-ClassSetRange">ClassSetRange</a></emu-nt>
|
||
<emu-nt optional="" id="_ref_24058"><a href="text-processing.html#prod-ClassUnion">ClassUnion</a><emu-mods><emu-opt>opt</emu-opt></emu-mods></emu-nt>
|
||
</emu-rhs>
|
||
<emu-rhs a="ga57bqew" id="prod-x32ygNst">
|
||
<emu-nt id="_ref_24059"><a href="text-processing.html#prod-ClassSetOperand">ClassSetOperand</a></emu-nt>
|
||
<emu-nt optional="" id="_ref_24060"><a href="text-processing.html#prod-ClassUnion">ClassUnion</a><emu-mods><emu-opt>opt</emu-opt></emu-mods></emu-nt>
|
||
</emu-rhs>
|
||
</emu-production>
|
||
<emu-production name="ClassIntersection" type="lexical" id="prod-ClassIntersection">
|
||
<emu-nt><a href="text-processing.html#prod-ClassIntersection">ClassIntersection</a></emu-nt> <emu-geq>::</emu-geq> <emu-rhs a="7h6yrwnx" id="prod-pPEC03dD">
|
||
<emu-nt id="_ref_24061"><a href="text-processing.html#prod-ClassSetOperand">ClassSetOperand</a></emu-nt>
|
||
<emu-t>&&</emu-t>
|
||
<emu-gann>[lookahead ≠ <emu-t>&</emu-t>]</emu-gann>
|
||
<emu-nt id="_ref_24062"><a href="text-processing.html#prod-ClassSetOperand">ClassSetOperand</a></emu-nt>
|
||
</emu-rhs>
|
||
<emu-rhs a="havb7zmx" id="prod-t1FOWCCV">
|
||
<emu-nt id="_ref_24063"><a href="text-processing.html#prod-ClassIntersection">ClassIntersection</a></emu-nt>
|
||
<emu-t>&&</emu-t>
|
||
<emu-gann>[lookahead ≠ <emu-t>&</emu-t>]</emu-gann>
|
||
<emu-nt id="_ref_24064"><a href="text-processing.html#prod-ClassSetOperand">ClassSetOperand</a></emu-nt>
|
||
</emu-rhs>
|
||
</emu-production>
|
||
<emu-production name="ClassSubtraction" type="lexical" id="prod-ClassSubtraction">
|
||
<emu-nt><a href="text-processing.html#prod-ClassSubtraction">ClassSubtraction</a></emu-nt> <emu-geq>::</emu-geq> <emu-rhs a="0iwjxoz1" id="prod-ET7TxN9I">
|
||
<emu-nt id="_ref_24065"><a href="text-processing.html#prod-ClassSetOperand">ClassSetOperand</a></emu-nt>
|
||
<emu-t>--</emu-t>
|
||
<emu-nt id="_ref_24066"><a href="text-processing.html#prod-ClassSetOperand">ClassSetOperand</a></emu-nt>
|
||
</emu-rhs>
|
||
<emu-rhs a="pdtgdxpo" id="prod-EEppnL8M">
|
||
<emu-nt id="_ref_24067"><a href="text-processing.html#prod-ClassSubtraction">ClassSubtraction</a></emu-nt>
|
||
<emu-t>--</emu-t>
|
||
<emu-nt id="_ref_24068"><a href="text-processing.html#prod-ClassSetOperand">ClassSetOperand</a></emu-nt>
|
||
</emu-rhs>
|
||
</emu-production>
|
||
<emu-production name="ClassSetRange" type="lexical" id="prod-ClassSetRange">
|
||
<emu-nt><a href="text-processing.html#prod-ClassSetRange">ClassSetRange</a></emu-nt> <emu-geq>::</emu-geq> <emu-rhs a="olq8_w1t" id="prod-uyCI4Vm7">
|
||
<emu-nt id="_ref_24069"><a href="text-processing.html#prod-ClassSetCharacter">ClassSetCharacter</a></emu-nt>
|
||
<emu-t>-</emu-t>
|
||
<emu-nt id="_ref_24070"><a href="text-processing.html#prod-ClassSetCharacter">ClassSetCharacter</a></emu-nt>
|
||
</emu-rhs>
|
||
</emu-production>
|
||
<emu-production name="ClassSetOperand" type="lexical" id="prod-ClassSetOperand">
|
||
<emu-nt><a href="text-processing.html#prod-ClassSetOperand">ClassSetOperand</a></emu-nt> <emu-geq>::</emu-geq> <emu-rhs a="bz00qqkp" id="prod-j3hqQEKY">
|
||
<emu-nt id="_ref_24071"><a href="text-processing.html#prod-NestedClass">NestedClass</a></emu-nt>
|
||
</emu-rhs>
|
||
<emu-rhs a="gmk8rsml" id="prod-0J8lXMFz">
|
||
<emu-nt id="_ref_24072"><a href="text-processing.html#prod-ClassStringDisjunction">ClassStringDisjunction</a></emu-nt>
|
||
</emu-rhs>
|
||
<emu-rhs a="pbrz9y58" id="prod-lqRWpy0s">
|
||
<emu-nt id="_ref_24073"><a href="text-processing.html#prod-ClassSetCharacter">ClassSetCharacter</a></emu-nt>
|
||
</emu-rhs>
|
||
</emu-production>
|
||
<emu-production name="NestedClass" type="lexical" id="prod-NestedClass">
|
||
<emu-nt><a href="text-processing.html#prod-NestedClass">NestedClass</a></emu-nt> <emu-geq>::</emu-geq> <emu-rhs a="tupozqhe" id="prod-gbvVygeq">
|
||
<emu-t>[</emu-t>
|
||
<emu-gann>[lookahead ≠ <emu-t>^</emu-t>]</emu-gann>
|
||
<emu-nt params="+UnicodeMode, +UnicodeSetsMode" id="_ref_24074"><a href="text-processing.html#prod-ClassContents">ClassContents</a><emu-mods><emu-params>[+UnicodeMode, +UnicodeSetsMode]</emu-params></emu-mods></emu-nt>
|
||
<emu-t>]</emu-t>
|
||
</emu-rhs>
|
||
<emu-rhs a="t8lra7ts" id="prod-9Q7EpkJI">
|
||
<emu-t>[^</emu-t>
|
||
<emu-nt params="+UnicodeMode, +UnicodeSetsMode" id="_ref_24075"><a href="text-processing.html#prod-ClassContents">ClassContents</a><emu-mods><emu-params>[+UnicodeMode, +UnicodeSetsMode]</emu-params></emu-mods></emu-nt>
|
||
<emu-t>]</emu-t>
|
||
</emu-rhs>
|
||
<emu-rhs a="27fjovie" id="prod-NSfZaxtj">
|
||
<emu-t>\</emu-t>
|
||
<emu-nt params="+UnicodeMode" id="_ref_24076"><a href="text-processing.html#prod-CharacterClassEscape">CharacterClassEscape</a><emu-mods><emu-params>[+UnicodeMode]</emu-params></emu-mods></emu-nt>
|
||
</emu-rhs>
|
||
</emu-production>
|
||
</emu-grammar>
|
||
<emu-note><span class="note">Note 1</span><div class="note-contents">
|
||
<p>The first two lines here are equivalent to CharacterClass.</p>
|
||
</div></emu-note>
|
||
<emu-grammar type="definition"><emu-production name="ClassStringDisjunction" type="lexical" id="prod-ClassStringDisjunction">
|
||
<emu-nt><a href="text-processing.html#prod-ClassStringDisjunction">ClassStringDisjunction</a></emu-nt> <emu-geq>::</emu-geq> <emu-rhs a="kjbhn6ad" id="prod-OWA-RIEl">
|
||
<emu-t>\q{</emu-t>
|
||
<emu-nt id="_ref_24077"><a href="text-processing.html#prod-ClassStringDisjunctionContents">ClassStringDisjunctionContents</a></emu-nt>
|
||
<emu-t>}</emu-t>
|
||
</emu-rhs>
|
||
</emu-production>
|
||
<emu-production name="ClassStringDisjunctionContents" type="lexical" id="prod-ClassStringDisjunctionContents">
|
||
<emu-nt><a href="text-processing.html#prod-ClassStringDisjunctionContents">ClassStringDisjunctionContents</a></emu-nt> <emu-geq>::</emu-geq> <emu-rhs a="-skvesn5" id="prod-4o44xqjO">
|
||
<emu-nt id="_ref_24078"><a href="text-processing.html#prod-ClassString">ClassString</a></emu-nt>
|
||
</emu-rhs>
|
||
<emu-rhs a="bsmwgovm" id="prod-RLq9E3c7">
|
||
<emu-nt id="_ref_24079"><a href="text-processing.html#prod-ClassString">ClassString</a></emu-nt>
|
||
<emu-t>|</emu-t>
|
||
<emu-nt id="_ref_24080"><a href="text-processing.html#prod-ClassStringDisjunctionContents">ClassStringDisjunctionContents</a></emu-nt>
|
||
</emu-rhs>
|
||
</emu-production>
|
||
<emu-production name="ClassString" type="lexical" id="prod-ClassString">
|
||
<emu-nt><a href="text-processing.html#prod-ClassString">ClassString</a></emu-nt> <emu-geq>::</emu-geq> <emu-rhs a="n7nathbb" id="prod-wlHjT_uF">
|
||
<emu-gann>[empty]</emu-gann>
|
||
</emu-rhs>
|
||
<emu-rhs a="zzzearnw" id="prod-R19M_TTI">
|
||
<emu-nt id="_ref_24081"><a href="text-processing.html#prod-NonEmptyClassString">NonEmptyClassString</a></emu-nt>
|
||
</emu-rhs>
|
||
</emu-production>
|
||
<emu-production name="NonEmptyClassString" type="lexical" id="prod-NonEmptyClassString">
|
||
<emu-nt><a href="text-processing.html#prod-NonEmptyClassString">NonEmptyClassString</a></emu-nt> <emu-geq>::</emu-geq> <emu-rhs a="g-kpie7v" id="prod-u7ZJYYBQ">
|
||
<emu-nt id="_ref_24082"><a href="text-processing.html#prod-ClassSetCharacter">ClassSetCharacter</a></emu-nt>
|
||
<emu-nt optional="" id="_ref_24083"><a href="text-processing.html#prod-NonEmptyClassString">NonEmptyClassString</a><emu-mods><emu-opt>opt</emu-opt></emu-mods></emu-nt>
|
||
</emu-rhs>
|
||
</emu-production>
|
||
<emu-production name="ClassSetCharacter" type="lexical" id="prod-ClassSetCharacter">
|
||
<emu-nt><a href="text-processing.html#prod-ClassSetCharacter">ClassSetCharacter</a></emu-nt> <emu-geq>::</emu-geq> <emu-rhs a="i1yszfyw" id="prod-aYRGZPo4">
|
||
<emu-gann>[lookahead ∉ <emu-nt id="_ref_24084"><a href="text-processing.html#prod-ClassSetReservedDoublePunctuator">ClassSetReservedDoublePunctuator</a></emu-nt>]</emu-gann>
|
||
<emu-nt id="_ref_24085"><a href="ecmascript-language-source-code.html#prod-SourceCharacter">SourceCharacter</a></emu-nt> <emu-gmod>but not <emu-nt id="_ref_24086"><a href="text-processing.html#prod-ClassSetSyntaxCharacter">ClassSetSyntaxCharacter</a></emu-nt></emu-gmod>
|
||
</emu-rhs>
|
||
<emu-rhs a="ytjgggtw" id="prod-K7v_V3OY">
|
||
<emu-t>\</emu-t>
|
||
<emu-nt params="+UnicodeMode" id="_ref_24087"><a href="text-processing.html#prod-CharacterEscape">CharacterEscape</a><emu-mods><emu-params>[+UnicodeMode]</emu-params></emu-mods></emu-nt>
|
||
</emu-rhs>
|
||
<emu-rhs a="xyoixwqd" id="prod-wURb2FX1">
|
||
<emu-t>\</emu-t>
|
||
<emu-nt id="_ref_24088"><a href="text-processing.html#prod-ClassSetReservedPunctuator">ClassSetReservedPunctuator</a></emu-nt>
|
||
</emu-rhs>
|
||
<emu-rhs a="axxsqknu" id="prod-3EeamNn_">
|
||
<emu-t>\b</emu-t>
|
||
</emu-rhs>
|
||
</emu-production>
|
||
<emu-production name="ClassSetReservedDoublePunctuator" type="lexical" oneof="" id="prod-ClassSetReservedDoublePunctuator">
|
||
<emu-nt><a href="text-processing.html#prod-ClassSetReservedDoublePunctuator">ClassSetReservedDoublePunctuator</a></emu-nt> <emu-geq>::</emu-geq> <emu-oneof>one of</emu-oneof> <emu-rhs><emu-t>&&</emu-t> <emu-t>!!</emu-t> <emu-t>##</emu-t> <emu-t>$$</emu-t> <emu-t>%%</emu-t> <emu-t>**</emu-t> <emu-t>++</emu-t> <emu-t>,,</emu-t> <emu-t>..</emu-t> <emu-t>::</emu-t> <emu-t>;;</emu-t> <emu-t><<</emu-t> <emu-t>==</emu-t> <emu-t>>></emu-t> <emu-t>??</emu-t> <emu-t>@@</emu-t> <emu-t>^^</emu-t> <emu-t>``</emu-t> <emu-t>~~</emu-t></emu-rhs>
|
||
</emu-production>
|
||
</emu-grammar>
|
||
<emu-grammar type="definition"><emu-production name="ClassSetSyntaxCharacter" type="lexical" oneof="" id="prod-ClassSetSyntaxCharacter">
|
||
<emu-nt><a href="text-processing.html#prod-ClassSetSyntaxCharacter">ClassSetSyntaxCharacter</a></emu-nt> <emu-geq>::</emu-geq> <emu-oneof>one of</emu-oneof> <emu-rhs><emu-t>(</emu-t> <emu-t>)</emu-t> <emu-t>[</emu-t> <emu-t>]</emu-t> <emu-t>{</emu-t> <emu-t>}</emu-t> <emu-t>/</emu-t> <emu-t>-</emu-t> <emu-t>\</emu-t> <emu-t>|</emu-t></emu-rhs>
|
||
</emu-production>
|
||
</emu-grammar>
|
||
<emu-grammar type="definition"><emu-production name="ClassSetReservedPunctuator" type="lexical" oneof="" id="prod-ClassSetReservedPunctuator">
|
||
<emu-nt><a href="text-processing.html#prod-ClassSetReservedPunctuator">ClassSetReservedPunctuator</a></emu-nt> <emu-geq>::</emu-geq> <emu-oneof>one of</emu-oneof> <emu-rhs><emu-t>&</emu-t> <emu-t>-</emu-t> <emu-t>!</emu-t> <emu-t>#</emu-t> <emu-t>%</emu-t> <emu-t>,</emu-t> <emu-t>:</emu-t> <emu-t>;</emu-t> <emu-t><</emu-t> <emu-t>=</emu-t> <emu-t>></emu-t> <emu-t>@</emu-t> <emu-t>`</emu-t> <emu-t>~</emu-t></emu-rhs>
|
||
</emu-production>
|
||
</emu-grammar>
|
||
<emu-note><span class="note">Note 2</span><div class="note-contents">
|
||
<p>A number of productions in this section are given alternative definitions in section <emu-xref href="#sec-regular-expressions-patterns" id="_ref_671"><a href="additional-ecmascript-features-for-web-browsers.html#sec-regular-expressions-patterns">B.1.2</a></emu-xref>.</p>
|
||
</div></emu-note>
|
||
|
||
<emu-clause id="sec-patterns-static-semantics-early-errors">
|
||
<h1><span class="secnum">22.2.1.1</span> Static Semantics: Early Errors</h1>
|
||
<emu-note><span class="note">Note</span><div class="note-contents">
|
||
<p>This section is amended in <emu-xref href="#sec-patterns-static-semantics-early-errors-annexb" id="_ref_672"><a href="additional-ecmascript-features-for-web-browsers.html#sec-patterns-static-semantics-early-errors-annexb">B.1.2.1</a></emu-xref>.</p>
|
||
</div></emu-note>
|
||
<emu-grammar><emu-production name="Pattern" type="lexical" collapsed="">
|
||
<emu-nt><a href="text-processing.html#prod-Pattern">Pattern</a></emu-nt> <emu-geq>::</emu-geq> <emu-rhs a="eaw70mcy"><emu-nt id="_ref_24089"><a href="text-processing.html#prod-Disjunction">Disjunction</a></emu-nt></emu-rhs>
|
||
</emu-production>
|
||
</emu-grammar>
|
||
<ul>
|
||
<li>
|
||
It is a Syntax Error if <emu-xref aoid="CountLeftCapturingParensWithin" id="_ref_11630"><a href="text-processing.html#sec-countleftcapturingparenswithin">CountLeftCapturingParensWithin</a></emu-xref>(<emu-nt id="_ref_24090"><a href="text-processing.html#prod-Pattern">Pattern</a></emu-nt>) ≥ 2<sup>32</sup> - 1.
|
||
</li>
|
||
<li>
|
||
It is a Syntax Error if <emu-nt id="_ref_24091"><a href="text-processing.html#prod-Pattern">Pattern</a></emu-nt> contains two distinct <emu-nt id="_ref_24092"><a href="text-processing.html#prod-GroupSpecifier">GroupSpecifier</a></emu-nt>s <var>x</var> and <var>y</var> such that the <emu-xref aoid="CapturingGroupName" id="_ref_11631"><a href="text-processing.html#sec-static-semantics-capturinggroupname">CapturingGroupName</a></emu-xref> of <var>x</var> is the <emu-xref aoid="CapturingGroupName" id="_ref_11632"><a href="text-processing.html#sec-static-semantics-capturinggroupname">CapturingGroupName</a></emu-xref> of <var>y</var> and such that <emu-xref aoid="MightBothParticipate" id="_ref_11633"><a href="text-processing.html#sec-mightbothparticipate">MightBothParticipate</a></emu-xref>(<var>x</var>, <var>y</var>) is <emu-val>true</emu-val>.
|
||
</li>
|
||
</ul>
|
||
<emu-grammar><emu-production name="QuantifierPrefix" type="lexical" collapsed="">
|
||
<emu-nt><a href="text-processing.html#prod-QuantifierPrefix">QuantifierPrefix</a></emu-nt> <emu-geq>::</emu-geq> <emu-rhs a="9hgpwdk0">
|
||
<emu-t>{</emu-t>
|
||
<emu-nt id="_ref_24093"><a href="ecmascript-language-lexical-grammar.html#prod-DecimalDigits">DecimalDigits</a></emu-nt>
|
||
<emu-t>,</emu-t>
|
||
<emu-nt id="_ref_24094"><a href="ecmascript-language-lexical-grammar.html#prod-DecimalDigits">DecimalDigits</a></emu-nt>
|
||
<emu-t>}</emu-t>
|
||
</emu-rhs>
|
||
</emu-production>
|
||
</emu-grammar>
|
||
<ul>
|
||
<li>
|
||
It is a Syntax Error if the MV of the first <emu-nt id="_ref_24095"><a href="ecmascript-language-lexical-grammar.html#prod-DecimalDigits">DecimalDigits</a></emu-nt> is strictly greater than the MV of the second <emu-nt id="_ref_24096"><a href="ecmascript-language-lexical-grammar.html#prod-DecimalDigits">DecimalDigits</a></emu-nt>.
|
||
</li>
|
||
</ul>
|
||
<emu-grammar><emu-production name="Atom" type="lexical" collapsed="">
|
||
<emu-nt><a href="text-processing.html#prod-Atom">Atom</a></emu-nt> <emu-geq>::</emu-geq> <emu-rhs a="a-bf9noz">
|
||
<emu-t>(?</emu-t>
|
||
<emu-nt id="_ref_24097"><a href="text-processing.html#prod-RegularExpressionModifiers">RegularExpressionModifiers</a></emu-nt>
|
||
<emu-t>:</emu-t>
|
||
<emu-nt id="_ref_24098"><a href="text-processing.html#prod-Disjunction">Disjunction</a></emu-nt>
|
||
<emu-t>)</emu-t>
|
||
</emu-rhs>
|
||
</emu-production>
|
||
</emu-grammar>
|
||
<ul>
|
||
<li>
|
||
It is a Syntax Error if the <emu-xref href="#sec-algorithm-conventions-syntax-directed-operations" id="_ref_11634"><a href="notational-conventions.html#sec-algorithm-conventions-syntax-directed-operations">source text matched by</a></emu-xref> <emu-nt id="_ref_24099"><a href="text-processing.html#prod-RegularExpressionModifiers">RegularExpressionModifiers</a></emu-nt> contains the same code point more than once.
|
||
</li>
|
||
</ul>
|
||
<emu-grammar><emu-production name="Atom" type="lexical" collapsed="">
|
||
<emu-nt><a href="text-processing.html#prod-Atom">Atom</a></emu-nt> <emu-geq>::</emu-geq> <emu-rhs a="qocvabie">
|
||
<emu-t>(?</emu-t>
|
||
<emu-nt id="_ref_24100"><a href="text-processing.html#prod-RegularExpressionModifiers">RegularExpressionModifiers</a></emu-nt>
|
||
<emu-t>-</emu-t>
|
||
<emu-nt id="_ref_24101"><a href="text-processing.html#prod-RegularExpressionModifiers">RegularExpressionModifiers</a></emu-nt>
|
||
<emu-t>:</emu-t>
|
||
<emu-nt id="_ref_24102"><a href="text-processing.html#prod-Disjunction">Disjunction</a></emu-nt>
|
||
<emu-t>)</emu-t>
|
||
</emu-rhs>
|
||
</emu-production>
|
||
</emu-grammar>
|
||
<ul>
|
||
<li>
|
||
It is a Syntax Error if the <emu-xref href="#sec-algorithm-conventions-syntax-directed-operations" id="_ref_11635"><a href="notational-conventions.html#sec-algorithm-conventions-syntax-directed-operations">source text matched by</a></emu-xref> the first <emu-nt id="_ref_24103"><a href="text-processing.html#prod-RegularExpressionModifiers">RegularExpressionModifiers</a></emu-nt> and the <emu-xref href="#sec-algorithm-conventions-syntax-directed-operations" id="_ref_11636"><a href="notational-conventions.html#sec-algorithm-conventions-syntax-directed-operations">source text matched by</a></emu-xref> the second <emu-nt id="_ref_24104"><a href="text-processing.html#prod-RegularExpressionModifiers">RegularExpressionModifiers</a></emu-nt> are both empty.
|
||
</li>
|
||
<li>
|
||
It is a Syntax Error if the <emu-xref href="#sec-algorithm-conventions-syntax-directed-operations" id="_ref_11637"><a href="notational-conventions.html#sec-algorithm-conventions-syntax-directed-operations">source text matched by</a></emu-xref> the first <emu-nt id="_ref_24105"><a href="text-processing.html#prod-RegularExpressionModifiers">RegularExpressionModifiers</a></emu-nt> contains the same code point more than once.
|
||
</li>
|
||
<li>
|
||
It is a Syntax Error if the <emu-xref href="#sec-algorithm-conventions-syntax-directed-operations" id="_ref_11638"><a href="notational-conventions.html#sec-algorithm-conventions-syntax-directed-operations">source text matched by</a></emu-xref> the second <emu-nt id="_ref_24106"><a href="text-processing.html#prod-RegularExpressionModifiers">RegularExpressionModifiers</a></emu-nt> contains the same code point more than once.
|
||
</li>
|
||
<li>
|
||
It is a Syntax Error if any code point in the <emu-xref href="#sec-algorithm-conventions-syntax-directed-operations" id="_ref_11639"><a href="notational-conventions.html#sec-algorithm-conventions-syntax-directed-operations">source text matched by</a></emu-xref> the first <emu-nt id="_ref_24107"><a href="text-processing.html#prod-RegularExpressionModifiers">RegularExpressionModifiers</a></emu-nt> is also contained in the <emu-xref href="#sec-algorithm-conventions-syntax-directed-operations" id="_ref_11640"><a href="notational-conventions.html#sec-algorithm-conventions-syntax-directed-operations">source text matched by</a></emu-xref> the second <emu-nt id="_ref_24108"><a href="text-processing.html#prod-RegularExpressionModifiers">RegularExpressionModifiers</a></emu-nt>.
|
||
</li>
|
||
</ul>
|
||
<emu-grammar><emu-production name="AtomEscape" type="lexical" collapsed="">
|
||
<emu-nt><a href="text-processing.html#prod-AtomEscape">AtomEscape</a></emu-nt> <emu-geq>::</emu-geq> <emu-rhs a="dd_xjonr">
|
||
<emu-t>k</emu-t>
|
||
<emu-nt id="_ref_24109"><a href="text-processing.html#prod-GroupName">GroupName</a></emu-nt>
|
||
</emu-rhs>
|
||
</emu-production>
|
||
</emu-grammar>
|
||
<ul>
|
||
<li>
|
||
It is a Syntax Error if <emu-xref aoid="GroupSpecifiersThatMatch" id="_ref_11641"><a href="text-processing.html#sec-groupspecifiersthatmatch">GroupSpecifiersThatMatch</a></emu-xref>(<emu-nt id="_ref_24110"><a href="text-processing.html#prod-GroupName">GroupName</a></emu-nt>) is empty.
|
||
</li>
|
||
</ul>
|
||
<emu-grammar><emu-production name="AtomEscape" type="lexical" collapsed="">
|
||
<emu-nt><a href="text-processing.html#prod-AtomEscape">AtomEscape</a></emu-nt> <emu-geq>::</emu-geq> <emu-rhs a="fr_5bnut"><emu-nt id="_ref_24111"><a href="text-processing.html#prod-DecimalEscape">DecimalEscape</a></emu-nt></emu-rhs>
|
||
</emu-production>
|
||
</emu-grammar>
|
||
<ul>
|
||
<li>
|
||
It is a Syntax Error if the <emu-xref aoid="CapturingGroupNumber" id="_ref_11642"><a href="text-processing.html#sec-patterns-static-semantics-capturing-group-number">CapturingGroupNumber</a></emu-xref> of <emu-nt id="_ref_24112"><a href="text-processing.html#prod-DecimalEscape">DecimalEscape</a></emu-nt> is strictly greater than <emu-xref aoid="CountLeftCapturingParensWithin" id="_ref_11643"><a href="text-processing.html#sec-countleftcapturingparenswithin">CountLeftCapturingParensWithin</a></emu-xref>(the <emu-nt id="_ref_24113"><a href="text-processing.html#prod-Pattern">Pattern</a></emu-nt> containing <emu-nt id="_ref_24114"><a href="text-processing.html#prod-AtomEscape">AtomEscape</a></emu-nt>).
|
||
</li>
|
||
</ul>
|
||
<emu-grammar><emu-production name="NonemptyClassRanges" type="lexical" collapsed="">
|
||
<emu-nt><a href="text-processing.html#prod-NonemptyClassRanges">NonemptyClassRanges</a></emu-nt> <emu-geq>::</emu-geq> <emu-rhs a="2bs-sw8o">
|
||
<emu-nt id="_ref_24115"><a href="text-processing.html#prod-ClassAtom">ClassAtom</a></emu-nt>
|
||
<emu-t>-</emu-t>
|
||
<emu-nt id="_ref_24116"><a href="text-processing.html#prod-ClassAtom">ClassAtom</a></emu-nt>
|
||
<emu-nt id="_ref_24117"><a href="text-processing.html#prod-ClassContents">ClassContents</a></emu-nt>
|
||
</emu-rhs>
|
||
</emu-production>
|
||
</emu-grammar>
|
||
<ul>
|
||
<li>
|
||
It is a Syntax Error if <emu-xref aoid="IsCharacterClass" id="_ref_11644"><a href="text-processing.html#sec-patterns-static-semantics-is-character-class">IsCharacterClass</a></emu-xref> of the first <emu-nt id="_ref_24118"><a href="text-processing.html#prod-ClassAtom">ClassAtom</a></emu-nt> is <emu-val>true</emu-val> or <emu-xref aoid="IsCharacterClass" id="_ref_11645"><a href="text-processing.html#sec-patterns-static-semantics-is-character-class">IsCharacterClass</a></emu-xref> of the second <emu-nt id="_ref_24119"><a href="text-processing.html#prod-ClassAtom">ClassAtom</a></emu-nt> is <emu-val>true</emu-val>.
|
||
</li>
|
||
<li>
|
||
It is a Syntax Error if <emu-xref aoid="IsCharacterClass" id="_ref_11646"><a href="text-processing.html#sec-patterns-static-semantics-is-character-class">IsCharacterClass</a></emu-xref> of the first <emu-nt id="_ref_24120"><a href="text-processing.html#prod-ClassAtom">ClassAtom</a></emu-nt> is <emu-val>false</emu-val>, <emu-xref aoid="IsCharacterClass" id="_ref_11647"><a href="text-processing.html#sec-patterns-static-semantics-is-character-class">IsCharacterClass</a></emu-xref> of the second <emu-nt id="_ref_24121"><a href="text-processing.html#prod-ClassAtom">ClassAtom</a></emu-nt> is <emu-val>false</emu-val>, and the <emu-xref aoid="CharacterValue" id="_ref_11648"><a href="text-processing.html#sec-patterns-static-semantics-character-value">CharacterValue</a></emu-xref> of the first <emu-nt id="_ref_24122"><a href="text-processing.html#prod-ClassAtom">ClassAtom</a></emu-nt> is strictly greater than the <emu-xref aoid="CharacterValue" id="_ref_11649"><a href="text-processing.html#sec-patterns-static-semantics-character-value">CharacterValue</a></emu-xref> of the second <emu-nt id="_ref_24123"><a href="text-processing.html#prod-ClassAtom">ClassAtom</a></emu-nt>.
|
||
</li>
|
||
</ul>
|
||
<emu-grammar><emu-production name="NonemptyClassRangesNoDash" type="lexical" collapsed="">
|
||
<emu-nt><a href="text-processing.html#prod-NonemptyClassRangesNoDash">NonemptyClassRangesNoDash</a></emu-nt> <emu-geq>::</emu-geq> <emu-rhs a="udwlha-v">
|
||
<emu-nt id="_ref_24124"><a href="text-processing.html#prod-ClassAtomNoDash">ClassAtomNoDash</a></emu-nt>
|
||
<emu-t>-</emu-t>
|
||
<emu-nt id="_ref_24125"><a href="text-processing.html#prod-ClassAtom">ClassAtom</a></emu-nt>
|
||
<emu-nt id="_ref_24126"><a href="text-processing.html#prod-ClassContents">ClassContents</a></emu-nt>
|
||
</emu-rhs>
|
||
</emu-production>
|
||
</emu-grammar>
|
||
<ul>
|
||
<li>
|
||
It is a Syntax Error if <emu-xref aoid="IsCharacterClass" id="_ref_11650"><a href="text-processing.html#sec-patterns-static-semantics-is-character-class">IsCharacterClass</a></emu-xref> of <emu-nt id="_ref_24127"><a href="text-processing.html#prod-ClassAtomNoDash">ClassAtomNoDash</a></emu-nt> is <emu-val>true</emu-val> or <emu-xref aoid="IsCharacterClass" id="_ref_11651"><a href="text-processing.html#sec-patterns-static-semantics-is-character-class">IsCharacterClass</a></emu-xref> of <emu-nt id="_ref_24128"><a href="text-processing.html#prod-ClassAtom">ClassAtom</a></emu-nt> is <emu-val>true</emu-val>.
|
||
</li>
|
||
<li>
|
||
It is a Syntax Error if <emu-xref aoid="IsCharacterClass" id="_ref_11652"><a href="text-processing.html#sec-patterns-static-semantics-is-character-class">IsCharacterClass</a></emu-xref> of <emu-nt id="_ref_24129"><a href="text-processing.html#prod-ClassAtomNoDash">ClassAtomNoDash</a></emu-nt> is <emu-val>false</emu-val>, <emu-xref aoid="IsCharacterClass" id="_ref_11653"><a href="text-processing.html#sec-patterns-static-semantics-is-character-class">IsCharacterClass</a></emu-xref> of <emu-nt id="_ref_24130"><a href="text-processing.html#prod-ClassAtom">ClassAtom</a></emu-nt> is <emu-val>false</emu-val>, and the <emu-xref aoid="CharacterValue" id="_ref_11654"><a href="text-processing.html#sec-patterns-static-semantics-character-value">CharacterValue</a></emu-xref> of <emu-nt id="_ref_24131"><a href="text-processing.html#prod-ClassAtomNoDash">ClassAtomNoDash</a></emu-nt> is strictly greater than the <emu-xref aoid="CharacterValue" id="_ref_11655"><a href="text-processing.html#sec-patterns-static-semantics-character-value">CharacterValue</a></emu-xref> of <emu-nt id="_ref_24132"><a href="text-processing.html#prod-ClassAtom">ClassAtom</a></emu-nt>.
|
||
</li>
|
||
</ul>
|
||
<emu-grammar><emu-production name="RegExpIdentifierStart" type="lexical" collapsed="">
|
||
<emu-nt><a href="text-processing.html#prod-RegExpIdentifierStart">RegExpIdentifierStart</a></emu-nt> <emu-geq>::</emu-geq> <emu-rhs a="vkfrbm2v">
|
||
<emu-t>\</emu-t>
|
||
<emu-nt id="_ref_24133"><a href="text-processing.html#prod-RegExpUnicodeEscapeSequence">RegExpUnicodeEscapeSequence</a></emu-nt>
|
||
</emu-rhs>
|
||
</emu-production>
|
||
</emu-grammar>
|
||
<ul>
|
||
<li>
|
||
It is a Syntax Error if the <emu-xref aoid="CharacterValue" id="_ref_11656"><a href="text-processing.html#sec-patterns-static-semantics-character-value">CharacterValue</a></emu-xref> of <emu-nt id="_ref_24134"><a href="text-processing.html#prod-RegExpUnicodeEscapeSequence">RegExpUnicodeEscapeSequence</a></emu-nt> is not the numeric value of some code point matched by the <emu-nt id="_ref_24135"><a href="ecmascript-language-lexical-grammar.html#prod-IdentifierStartChar">IdentifierStartChar</a></emu-nt> lexical grammar production.
|
||
</li>
|
||
</ul>
|
||
<emu-grammar><emu-production name="RegExpIdentifierStart" type="lexical" collapsed="">
|
||
<emu-nt><a href="text-processing.html#prod-RegExpIdentifierStart">RegExpIdentifierStart</a></emu-nt> <emu-geq>::</emu-geq> <emu-rhs a="-hbnr2gv">
|
||
<emu-nt id="_ref_24136"><a href="text-processing.html#prod-UnicodeLeadSurrogate">UnicodeLeadSurrogate</a></emu-nt>
|
||
<emu-nt id="_ref_24137"><a href="text-processing.html#prod-UnicodeTrailSurrogate">UnicodeTrailSurrogate</a></emu-nt>
|
||
</emu-rhs>
|
||
</emu-production>
|
||
</emu-grammar>
|
||
<ul>
|
||
<li>
|
||
It is a Syntax Error if the <emu-xref aoid="RegExpIdentifierCodePoint" id="_ref_11657"><a href="text-processing.html#sec-regexpidentifiercodepoint">RegExpIdentifierCodePoint</a></emu-xref> of <emu-nt id="_ref_24138"><a href="text-processing.html#prod-RegExpIdentifierStart">RegExpIdentifierStart</a></emu-nt> is not matched by the <emu-nt id="_ref_24139"><a href="ecmascript-language-lexical-grammar.html#prod-UnicodeIDStart">UnicodeIDStart</a></emu-nt> lexical grammar production.
|
||
</li>
|
||
</ul>
|
||
<emu-grammar><emu-production name="RegExpIdentifierPart" type="lexical" collapsed="">
|
||
<emu-nt><a href="text-processing.html#prod-RegExpIdentifierPart">RegExpIdentifierPart</a></emu-nt> <emu-geq>::</emu-geq> <emu-rhs a="vkfrbm2v">
|
||
<emu-t>\</emu-t>
|
||
<emu-nt id="_ref_24140"><a href="text-processing.html#prod-RegExpUnicodeEscapeSequence">RegExpUnicodeEscapeSequence</a></emu-nt>
|
||
</emu-rhs>
|
||
</emu-production>
|
||
</emu-grammar>
|
||
<ul>
|
||
<li>
|
||
It is a Syntax Error if the <emu-xref aoid="CharacterValue" id="_ref_11658"><a href="text-processing.html#sec-patterns-static-semantics-character-value">CharacterValue</a></emu-xref> of <emu-nt id="_ref_24141"><a href="text-processing.html#prod-RegExpUnicodeEscapeSequence">RegExpUnicodeEscapeSequence</a></emu-nt> is not the numeric value of some code point matched by the <emu-nt id="_ref_24142"><a href="ecmascript-language-lexical-grammar.html#prod-IdentifierPartChar">IdentifierPartChar</a></emu-nt> lexical grammar production.
|
||
</li>
|
||
</ul>
|
||
<emu-grammar><emu-production name="RegExpIdentifierPart" type="lexical" collapsed="">
|
||
<emu-nt><a href="text-processing.html#prod-RegExpIdentifierPart">RegExpIdentifierPart</a></emu-nt> <emu-geq>::</emu-geq> <emu-rhs a="-hbnr2gv">
|
||
<emu-nt id="_ref_24143"><a href="text-processing.html#prod-UnicodeLeadSurrogate">UnicodeLeadSurrogate</a></emu-nt>
|
||
<emu-nt id="_ref_24144"><a href="text-processing.html#prod-UnicodeTrailSurrogate">UnicodeTrailSurrogate</a></emu-nt>
|
||
</emu-rhs>
|
||
</emu-production>
|
||
</emu-grammar>
|
||
<ul>
|
||
<li>
|
||
It is a Syntax Error if the <emu-xref aoid="RegExpIdentifierCodePoint" id="_ref_11659"><a href="text-processing.html#sec-regexpidentifiercodepoint">RegExpIdentifierCodePoint</a></emu-xref> of <emu-nt id="_ref_24145"><a href="text-processing.html#prod-RegExpIdentifierPart">RegExpIdentifierPart</a></emu-nt> is not matched by the <emu-nt id="_ref_24146"><a href="ecmascript-language-lexical-grammar.html#prod-UnicodeIDContinue">UnicodeIDContinue</a></emu-nt> lexical grammar production.
|
||
</li>
|
||
</ul>
|
||
<emu-grammar><emu-production name="UnicodePropertyValueExpression" type="lexical" collapsed="">
|
||
<emu-nt><a href="text-processing.html#prod-UnicodePropertyValueExpression">UnicodePropertyValueExpression</a></emu-nt> <emu-geq>::</emu-geq> <emu-rhs a="sr3kbwzj">
|
||
<emu-nt id="_ref_24147"><a href="text-processing.html#prod-UnicodePropertyName">UnicodePropertyName</a></emu-nt>
|
||
<emu-t>=</emu-t>
|
||
<emu-nt id="_ref_24148"><a href="text-processing.html#prod-UnicodePropertyValue">UnicodePropertyValue</a></emu-nt>
|
||
</emu-rhs>
|
||
</emu-production>
|
||
</emu-grammar>
|
||
<ul>
|
||
<li>
|
||
It is a Syntax Error if the <emu-xref href="#sec-algorithm-conventions-syntax-directed-operations" id="_ref_11660"><a href="notational-conventions.html#sec-algorithm-conventions-syntax-directed-operations">source text matched by</a></emu-xref> <emu-nt id="_ref_24149"><a href="text-processing.html#prod-UnicodePropertyName">UnicodePropertyName</a></emu-nt> is not a <emu-not-ref>Unicode property name</emu-not-ref> or property alias listed in the “<emu-not-ref>Property name and aliases</emu-not-ref>” column of <emu-xref href="#table-nonbinary-unicode-properties" id="_ref_673"><a href="text-processing.html#table-nonbinary-unicode-properties">Table 64</a></emu-xref>.
|
||
</li>
|
||
<li>
|
||
It is a Syntax Error if the <emu-xref href="#sec-algorithm-conventions-syntax-directed-operations" id="_ref_11661"><a href="notational-conventions.html#sec-algorithm-conventions-syntax-directed-operations">source text matched by</a></emu-xref> <emu-nt id="_ref_24150"><a href="text-processing.html#prod-UnicodePropertyValue">UnicodePropertyValue</a></emu-nt> is not a property value or property value alias for the Unicode property or property alias given by the <emu-xref href="#sec-algorithm-conventions-syntax-directed-operations" id="_ref_11662"><a href="notational-conventions.html#sec-algorithm-conventions-syntax-directed-operations">source text matched by</a></emu-xref> <emu-nt id="_ref_24151"><a href="text-processing.html#prod-UnicodePropertyName">UnicodePropertyName</a></emu-nt> listed in <a href="https://unicode.org/Public/UCD/latest/ucd/PropertyValueAliases.txt"><code>PropertyValueAliases.txt</code></a>.
|
||
</li>
|
||
</ul>
|
||
<emu-grammar><emu-production name="UnicodePropertyValueExpression" type="lexical" collapsed="">
|
||
<emu-nt><a href="text-processing.html#prod-UnicodePropertyValueExpression">UnicodePropertyValueExpression</a></emu-nt> <emu-geq>::</emu-geq> <emu-rhs a="jdlbklv9"><emu-nt id="_ref_24152"><a href="text-processing.html#prod-LoneUnicodePropertyNameOrValue">LoneUnicodePropertyNameOrValue</a></emu-nt></emu-rhs>
|
||
</emu-production>
|
||
</emu-grammar>
|
||
<ul>
|
||
<li>
|
||
It is a Syntax Error if the <emu-xref href="#sec-algorithm-conventions-syntax-directed-operations" id="_ref_11663"><a href="notational-conventions.html#sec-algorithm-conventions-syntax-directed-operations">source text matched by</a></emu-xref> <emu-nt id="_ref_24153"><a href="text-processing.html#prod-LoneUnicodePropertyNameOrValue">LoneUnicodePropertyNameOrValue</a></emu-nt> is not a Unicode property value or property value alias for the General_Category (gc) property listed in <a href="https://unicode.org/Public/UCD/latest/ucd/PropertyValueAliases.txt"><code>PropertyValueAliases.txt</code></a>, nor a binary property or binary property alias listed in the “<emu-not-ref>Property name and aliases</emu-not-ref>” column of <emu-xref href="#table-binary-unicode-properties" id="_ref_674"><a href="text-processing.html#table-binary-unicode-properties">Table 65</a></emu-xref>, nor a binary property of strings listed in the “<emu-not-ref>Property name</emu-not-ref>” column of <emu-xref href="#table-binary-unicode-properties-of-strings" id="_ref_675"><a href="text-processing.html#table-binary-unicode-properties-of-strings">Table 66</a></emu-xref>.
|
||
</li>
|
||
<li>
|
||
It is a Syntax Error if the enclosing <emu-nt id="_ref_24154"><a href="text-processing.html#prod-Pattern">Pattern</a></emu-nt> does not have a <sub>[UnicodeSetsMode]</sub> parameter and the <emu-xref href="#sec-algorithm-conventions-syntax-directed-operations" id="_ref_11664"><a href="notational-conventions.html#sec-algorithm-conventions-syntax-directed-operations">source text matched by</a></emu-xref> <emu-nt id="_ref_24155"><a href="text-processing.html#prod-LoneUnicodePropertyNameOrValue">LoneUnicodePropertyNameOrValue</a></emu-nt> is a binary property of strings listed in the “<emu-not-ref>Property name</emu-not-ref>” column of <emu-xref href="#table-binary-unicode-properties-of-strings" id="_ref_676"><a href="text-processing.html#table-binary-unicode-properties-of-strings">Table 66</a></emu-xref>.
|
||
</li>
|
||
</ul>
|
||
<emu-grammar><emu-production name="CharacterClassEscape" type="lexical" collapsed="">
|
||
<emu-nt><a href="text-processing.html#prod-CharacterClassEscape">CharacterClassEscape</a></emu-nt> <emu-geq>::</emu-geq> <emu-rhs a="4og7ke5v">
|
||
<emu-t>P{</emu-t>
|
||
<emu-nt id="_ref_24156"><a href="text-processing.html#prod-UnicodePropertyValueExpression">UnicodePropertyValueExpression</a></emu-nt>
|
||
<emu-t>}</emu-t>
|
||
</emu-rhs>
|
||
</emu-production>
|
||
</emu-grammar>
|
||
<ul>
|
||
<li>
|
||
It is a Syntax Error if <emu-xref aoid="MayContainStrings" id="_ref_11665"><a href="text-processing.html#sec-static-semantics-maycontainstrings">MayContainStrings</a></emu-xref> of the <emu-nt id="_ref_24157"><a href="text-processing.html#prod-UnicodePropertyValueExpression">UnicodePropertyValueExpression</a></emu-nt> is <emu-val>true</emu-val>.
|
||
</li>
|
||
</ul>
|
||
<emu-grammar><emu-production name="CharacterClass" type="lexical" collapsed="">
|
||
<emu-nt><a href="text-processing.html#prod-CharacterClass">CharacterClass</a></emu-nt> <emu-geq>::</emu-geq> <emu-rhs a="d-swr39f">
|
||
<emu-t>[^</emu-t>
|
||
<emu-nt id="_ref_24158"><a href="text-processing.html#prod-ClassContents">ClassContents</a></emu-nt>
|
||
<emu-t>]</emu-t>
|
||
</emu-rhs>
|
||
</emu-production>
|
||
</emu-grammar>
|
||
<ul>
|
||
<li>
|
||
It is a Syntax Error if <emu-xref aoid="MayContainStrings" id="_ref_11666"><a href="text-processing.html#sec-static-semantics-maycontainstrings">MayContainStrings</a></emu-xref> of the <emu-nt id="_ref_24159"><a href="text-processing.html#prod-ClassContents">ClassContents</a></emu-nt> is <emu-val>true</emu-val>.
|
||
</li>
|
||
</ul>
|
||
<emu-grammar><emu-production name="NestedClass" type="lexical" collapsed="">
|
||
<emu-nt><a href="text-processing.html#prod-NestedClass">NestedClass</a></emu-nt> <emu-geq>::</emu-geq> <emu-rhs a="d-swr39f">
|
||
<emu-t>[^</emu-t>
|
||
<emu-nt id="_ref_24160"><a href="text-processing.html#prod-ClassContents">ClassContents</a></emu-nt>
|
||
<emu-t>]</emu-t>
|
||
</emu-rhs>
|
||
</emu-production>
|
||
</emu-grammar>
|
||
<ul>
|
||
<li>
|
||
It is a Syntax Error if <emu-xref aoid="MayContainStrings" id="_ref_11667"><a href="text-processing.html#sec-static-semantics-maycontainstrings">MayContainStrings</a></emu-xref> of the <emu-nt id="_ref_24161"><a href="text-processing.html#prod-ClassContents">ClassContents</a></emu-nt> is <emu-val>true</emu-val>.
|
||
</li>
|
||
</ul>
|
||
<emu-grammar><emu-production name="ClassSetRange" type="lexical" collapsed="">
|
||
<emu-nt><a href="text-processing.html#prod-ClassSetRange">ClassSetRange</a></emu-nt> <emu-geq>::</emu-geq> <emu-rhs a="olq8_w1t">
|
||
<emu-nt id="_ref_24162"><a href="text-processing.html#prod-ClassSetCharacter">ClassSetCharacter</a></emu-nt>
|
||
<emu-t>-</emu-t>
|
||
<emu-nt id="_ref_24163"><a href="text-processing.html#prod-ClassSetCharacter">ClassSetCharacter</a></emu-nt>
|
||
</emu-rhs>
|
||
</emu-production>
|
||
</emu-grammar>
|
||
<ul>
|
||
<li>
|
||
It is a Syntax Error if the <emu-xref aoid="CharacterValue" id="_ref_11668"><a href="text-processing.html#sec-patterns-static-semantics-character-value">CharacterValue</a></emu-xref> of the first <emu-nt id="_ref_24164"><a href="text-processing.html#prod-ClassSetCharacter">ClassSetCharacter</a></emu-nt> is strictly greater than the <emu-xref aoid="CharacterValue" id="_ref_11669"><a href="text-processing.html#sec-patterns-static-semantics-character-value">CharacterValue</a></emu-xref> of the second <emu-nt id="_ref_24165"><a href="text-processing.html#prod-ClassSetCharacter">ClassSetCharacter</a></emu-nt>.
|
||
</li>
|
||
</ul>
|
||
</emu-clause>
|
||
|
||
<emu-clause id="sec-countleftcapturingparenswithin" type="abstract operation" aoid="CountLeftCapturingParensWithin">
|
||
<h1><span class="secnum">22.2.1.2</span> Static Semantics: CountLeftCapturingParensWithin ( <var>node</var> )</h1>
|
||
<p>The abstract operation CountLeftCapturingParensWithin takes argument <var>node</var> (a <emu-xref href="#sec-syntactic-grammar" id="_ref_11670"><a href="notational-conventions.html#sec-syntactic-grammar">Parse Node</a></emu-xref>) and returns a non-negative <emu-xref href="#integer" id="_ref_11671"><a href="notational-conventions.html#integer">integer</a></emu-xref>. It returns the number of left-capturing parentheses in <var>node</var>. A <dfn variants="left-capturing parentheses" tabindex="-1">left-capturing parenthesis</dfn> is any <code>(</code> pattern character that is matched by the <code>(</code> terminal of the <emu-grammar><emu-production name="Atom" type="lexical" collapsed="" class=" inline">
|
||
<emu-nt><a href="text-processing.html#prod-Atom">Atom</a></emu-nt> <emu-geq>::</emu-geq> <emu-rhs a="lnltxn63">
|
||
<emu-t>(</emu-t>
|
||
<emu-nt optional="" id="_ref_24166"><a href="text-processing.html#prod-GroupSpecifier">GroupSpecifier</a><emu-mods><emu-opt>opt</emu-opt></emu-mods></emu-nt>
|
||
<emu-nt id="_ref_24167"><a href="text-processing.html#prod-Disjunction">Disjunction</a></emu-nt>
|
||
<emu-t>)</emu-t>
|
||
</emu-rhs>
|
||
</emu-production>
|
||
</emu-grammar> production.</p>
|
||
<emu-note><span class="note">Note</span><div class="note-contents">
|
||
<p>This section is amended in <emu-xref href="#sec-countleftcapturingparens-annexb" id="_ref_677"><a href="additional-ecmascript-features-for-web-browsers.html#sec-countleftcapturingparens-annexb">B.1.2.2</a></emu-xref>.</p>
|
||
</div></emu-note>
|
||
<p>It performs the following steps when called:</p>
|
||
<emu-alg><ol><li><emu-xref href="#assert" id="_ref_11672"><a href="notational-conventions.html#assert">Assert</a></emu-xref>: <var>node</var> is an instance of a production in <emu-xref href="#sec-patterns" id="_ref_678"><a href="text-processing.html#sec-patterns">the RegExp Pattern grammar</a></emu-xref>.</li><li>Return the number of <emu-grammar><emu-production name="Atom" type="lexical" collapsed="" class=" inline">
|
||
<emu-nt><a href="text-processing.html#prod-Atom">Atom</a></emu-nt> <emu-geq>::</emu-geq> <emu-rhs a="lnltxn63">
|
||
<emu-t>(</emu-t>
|
||
<emu-nt optional="" id="_ref_24168"><a href="text-processing.html#prod-GroupSpecifier">GroupSpecifier</a><emu-mods><emu-opt>opt</emu-opt></emu-mods></emu-nt>
|
||
<emu-nt id="_ref_24169"><a href="text-processing.html#prod-Disjunction">Disjunction</a></emu-nt>
|
||
<emu-t>)</emu-t>
|
||
</emu-rhs>
|
||
</emu-production>
|
||
</emu-grammar> <emu-xref href="#sec-syntactic-grammar" id="_ref_11673"><a href="notational-conventions.html#sec-syntactic-grammar">Parse Nodes</a></emu-xref> contained within <var>node</var>.</li></ol></emu-alg>
|
||
</emu-clause>
|
||
|
||
<emu-clause id="sec-countleftcapturingparensbefore" type="abstract operation" aoid="CountLeftCapturingParensBefore">
|
||
<h1><span class="secnum">22.2.1.3</span> Static Semantics: CountLeftCapturingParensBefore ( <var>node</var> )</h1>
|
||
<p>The abstract operation CountLeftCapturingParensBefore takes argument <var>node</var> (a <emu-xref href="#sec-syntactic-grammar" id="_ref_11674"><a href="notational-conventions.html#sec-syntactic-grammar">Parse Node</a></emu-xref>) and returns a non-negative <emu-xref href="#integer" id="_ref_11675"><a href="notational-conventions.html#integer">integer</a></emu-xref>. It returns the number of <emu-xref href="#sec-countleftcapturingparenswithin" id="_ref_11676"><a href="text-processing.html#sec-countleftcapturingparenswithin">left-capturing parentheses</a></emu-xref> within the enclosing pattern that occur to the left of <var>node</var>.</p>
|
||
<emu-note><span class="note">Note</span><div class="note-contents">
|
||
<p>This section is amended in <emu-xref href="#sec-countleftcapturingparens-annexb" id="_ref_679"><a href="additional-ecmascript-features-for-web-browsers.html#sec-countleftcapturingparens-annexb">B.1.2.2</a></emu-xref>.</p>
|
||
</div></emu-note>
|
||
<p>It performs the following steps when called:</p>
|
||
<emu-alg><ol><li><emu-xref href="#assert" id="_ref_11677"><a href="notational-conventions.html#assert">Assert</a></emu-xref>: <var>node</var> is an instance of a production in <emu-xref href="#sec-patterns" id="_ref_680"><a href="text-processing.html#sec-patterns">the RegExp Pattern grammar</a></emu-xref>.</li><li>Let <var>pattern</var> be the <emu-nt id="_ref_24170"><a href="text-processing.html#prod-Pattern">Pattern</a></emu-nt> containing <var>node</var>.</li><li>Return the number of <emu-grammar><emu-production name="Atom" type="lexical" collapsed="" class=" inline">
|
||
<emu-nt><a href="text-processing.html#prod-Atom">Atom</a></emu-nt> <emu-geq>::</emu-geq> <emu-rhs a="lnltxn63">
|
||
<emu-t>(</emu-t>
|
||
<emu-nt optional="" id="_ref_24171"><a href="text-processing.html#prod-GroupSpecifier">GroupSpecifier</a><emu-mods><emu-opt>opt</emu-opt></emu-mods></emu-nt>
|
||
<emu-nt id="_ref_24172"><a href="text-processing.html#prod-Disjunction">Disjunction</a></emu-nt>
|
||
<emu-t>)</emu-t>
|
||
</emu-rhs>
|
||
</emu-production>
|
||
</emu-grammar> <emu-xref href="#sec-syntactic-grammar" id="_ref_11678"><a href="notational-conventions.html#sec-syntactic-grammar">Parse Nodes</a></emu-xref> contained within <var>pattern</var> that either occur before <var>node</var> or contain <var>node</var>.</li></ol></emu-alg>
|
||
</emu-clause>
|
||
|
||
<emu-clause id="sec-mightbothparticipate" type="abstract operation" aoid="MightBothParticipate">
|
||
<h1><span class="secnum">22.2.1.4</span> Static Semantics: MightBothParticipate ( <var>x</var>, <var>y</var> )</h1>
|
||
<p>The abstract operation MightBothParticipate takes arguments <var>x</var> (a <emu-xref href="#sec-syntactic-grammar" id="_ref_11679"><a href="notational-conventions.html#sec-syntactic-grammar">Parse Node</a></emu-xref>) and <var>y</var> (a <emu-xref href="#sec-syntactic-grammar" id="_ref_11680"><a href="notational-conventions.html#sec-syntactic-grammar">Parse Node</a></emu-xref>) and returns a Boolean. It performs the following steps when called:</p>
|
||
<emu-alg><ol><li><emu-xref href="#assert" id="_ref_11681"><a href="notational-conventions.html#assert">Assert</a></emu-xref>: <var>x</var> and <var>y</var> have the same enclosing <emu-nt id="_ref_24173"><a href="text-processing.html#prod-Pattern">Pattern</a></emu-nt>.</li><li>If the enclosing <emu-nt id="_ref_24174"><a href="text-processing.html#prod-Pattern">Pattern</a></emu-nt> contains a <emu-grammar><emu-production name="Disjunction" type="lexical" collapsed="" class=" inline">
|
||
<emu-nt><a href="text-processing.html#prod-Disjunction">Disjunction</a></emu-nt> <emu-geq>::</emu-geq> <emu-rhs a="jt2lba_1">
|
||
<emu-nt id="_ref_24175"><a href="text-processing.html#prod-Alternative">Alternative</a></emu-nt>
|
||
<emu-t>|</emu-t>
|
||
<emu-nt id="_ref_24176"><a href="text-processing.html#prod-Disjunction">Disjunction</a></emu-nt>
|
||
</emu-rhs>
|
||
</emu-production>
|
||
</emu-grammar> <emu-xref href="#sec-syntactic-grammar" id="_ref_11682"><a href="notational-conventions.html#sec-syntactic-grammar">Parse Node</a></emu-xref> such that either <var>x</var> is contained within the <emu-nt id="_ref_24177"><a href="text-processing.html#prod-Alternative">Alternative</a></emu-nt> and <var>y</var> is contained within the derived <emu-nt id="_ref_24178"><a href="text-processing.html#prod-Disjunction">Disjunction</a></emu-nt>, or <var>x</var> is contained within the derived <emu-nt id="_ref_24179"><a href="text-processing.html#prod-Disjunction">Disjunction</a></emu-nt> and <var>y</var> is contained within the <emu-nt id="_ref_24180"><a href="text-processing.html#prod-Alternative">Alternative</a></emu-nt>, return <emu-val>false</emu-val>.</li><li>Return <emu-val>true</emu-val>.</li></ol></emu-alg>
|
||
</emu-clause>
|
||
|
||
<emu-clause id="sec-patterns-static-semantics-capturing-group-number" type="sdo" aoid="CapturingGroupNumber">
|
||
<h1><span class="secnum">22.2.1.5</span> Static Semantics: CapturingGroupNumber</h1>
|
||
<p>The <emu-xref href="#sec-algorithm-conventions-syntax-directed-operations" id="_ref_11683"><a href="notational-conventions.html#sec-algorithm-conventions-syntax-directed-operations">syntax-directed operation</a></emu-xref> CapturingGroupNumber takes no arguments and returns a positive <emu-xref href="#integer" id="_ref_11684"><a href="notational-conventions.html#integer">integer</a></emu-xref>.</p>
|
||
<emu-note><span class="note">Note</span><div class="note-contents">
|
||
<p>This section is amended in <emu-xref href="#sec-patterns-static-semantics-early-errors-annexb" id="_ref_681"><a href="additional-ecmascript-features-for-web-browsers.html#sec-patterns-static-semantics-early-errors-annexb">B.1.2.1</a></emu-xref>.</p>
|
||
</div></emu-note>
|
||
<p>It is defined piecewise over the following productions:</p>
|
||
<emu-grammar><emu-production name="DecimalEscape" type="lexical" collapsed="">
|
||
<emu-nt><a href="text-processing.html#prod-DecimalEscape">DecimalEscape</a></emu-nt> <emu-geq>::</emu-geq> <emu-rhs a="1mot5ut_" id="prod-xT1sXsIe"><emu-nt id="_ref_24181"><a href="ecmascript-language-lexical-grammar.html#prod-NonZeroDigit">NonZeroDigit</a></emu-nt></emu-rhs>
|
||
</emu-production>
|
||
</emu-grammar>
|
||
<emu-alg><ol><li>Return the MV of <emu-nt id="_ref_24182"><a href="ecmascript-language-lexical-grammar.html#prod-NonZeroDigit">NonZeroDigit</a></emu-nt>.</li></ol></emu-alg>
|
||
<emu-grammar><emu-production name="DecimalEscape" type="lexical" collapsed="">
|
||
<emu-nt><a href="text-processing.html#prod-DecimalEscape">DecimalEscape</a></emu-nt> <emu-geq>::</emu-geq> <emu-rhs a="p0svd-i2" id="prod-lKRUpdJ5">
|
||
<emu-nt id="_ref_24183"><a href="ecmascript-language-lexical-grammar.html#prod-NonZeroDigit">NonZeroDigit</a></emu-nt>
|
||
<emu-nt id="_ref_24184"><a href="ecmascript-language-lexical-grammar.html#prod-DecimalDigits">DecimalDigits</a></emu-nt>
|
||
</emu-rhs>
|
||
</emu-production>
|
||
</emu-grammar>
|
||
<emu-alg><ol><li>Let <var>n</var> be the number of code points in <emu-nt id="_ref_24185"><a href="ecmascript-language-lexical-grammar.html#prod-DecimalDigits">DecimalDigits</a></emu-nt>.</li><li>Return (the MV of <emu-nt id="_ref_24186"><a href="ecmascript-language-lexical-grammar.html#prod-NonZeroDigit">NonZeroDigit</a></emu-nt> × 10<sup><var>n</var></sup> plus the MV of <emu-nt id="_ref_24187"><a href="ecmascript-language-lexical-grammar.html#prod-DecimalDigits">DecimalDigits</a></emu-nt>).</li></ol></emu-alg>
|
||
<p>The definitions of “the MV of <emu-nt id="_ref_24188"><a href="ecmascript-language-lexical-grammar.html#prod-NonZeroDigit">NonZeroDigit</a></emu-nt>” and “the MV of <emu-nt id="_ref_24189"><a href="ecmascript-language-lexical-grammar.html#prod-DecimalDigits">DecimalDigits</a></emu-nt>” are in <emu-xref href="#sec-literals-numeric-literals" id="_ref_682"><a href="ecmascript-language-lexical-grammar.html#sec-literals-numeric-literals">12.9.3</a></emu-xref>.</p>
|
||
</emu-clause>
|
||
|
||
<emu-clause id="sec-patterns-static-semantics-is-character-class" type="sdo" aoid="IsCharacterClass">
|
||
<h1><span class="secnum">22.2.1.6</span> Static Semantics: IsCharacterClass</h1>
|
||
<p>The <emu-xref href="#sec-algorithm-conventions-syntax-directed-operations" id="_ref_11685"><a href="notational-conventions.html#sec-algorithm-conventions-syntax-directed-operations">syntax-directed operation</a></emu-xref> IsCharacterClass takes no arguments and returns a Boolean.</p>
|
||
<emu-note><span class="note">Note</span><div class="note-contents">
|
||
<p>This section is amended in <emu-xref href="#sec-patterns-static-semantics-is-character-class-annexb" id="_ref_683"><a href="additional-ecmascript-features-for-web-browsers.html#sec-patterns-static-semantics-is-character-class-annexb">B.1.2.3</a></emu-xref>.</p>
|
||
</div></emu-note>
|
||
<p>It is defined piecewise over the following productions:</p>
|
||
<emu-grammar><emu-production name="ClassAtom" type="lexical">
|
||
<emu-nt><a href="text-processing.html#prod-ClassAtom">ClassAtom</a></emu-nt> <emu-geq>::</emu-geq> <emu-rhs a="byslh4l8" id="prod-G-2_KzF0">
|
||
<emu-t>-</emu-t>
|
||
</emu-rhs>
|
||
</emu-production>
|
||
<emu-production name="ClassAtomNoDash" type="lexical">
|
||
<emu-nt><a href="text-processing.html#prod-ClassAtomNoDash">ClassAtomNoDash</a></emu-nt> <emu-geq>::</emu-geq> <emu-rhs a="7n5ukjeb" id="prod-c9Gs2CyN">
|
||
<emu-nt id="_ref_24190"><a href="ecmascript-language-source-code.html#prod-SourceCharacter">SourceCharacter</a></emu-nt> <emu-gmod>but not one of <emu-t>\</emu-t> or <emu-t>]</emu-t> or <emu-t>-</emu-t></emu-gmod>
|
||
</emu-rhs>
|
||
</emu-production>
|
||
<emu-production name="ClassEscape" type="lexical">
|
||
<emu-nt><a href="text-processing.html#prod-ClassEscape">ClassEscape</a></emu-nt> <emu-geq>::</emu-geq> <emu-rhs a="ayxoiyyq" id="prod-CyWYzaiY">
|
||
<emu-t>b</emu-t>
|
||
</emu-rhs>
|
||
<emu-rhs a="byslh4l8" id="prod-_jzYJMTx">
|
||
<emu-t>-</emu-t>
|
||
</emu-rhs>
|
||
<emu-rhs a="fjarvpc8" id="prod-Z3nmWONm">
|
||
<emu-nt id="_ref_24191"><a href="text-processing.html#prod-CharacterEscape">CharacterEscape</a></emu-nt>
|
||
</emu-rhs>
|
||
</emu-production>
|
||
</emu-grammar>
|
||
<emu-alg><ol><li>Return <emu-val>false</emu-val>.</li></ol></emu-alg>
|
||
<emu-grammar><emu-production name="ClassEscape" type="lexical" collapsed="">
|
||
<emu-nt><a href="text-processing.html#prod-ClassEscape">ClassEscape</a></emu-nt> <emu-geq>::</emu-geq> <emu-rhs a="bww-5j2p" id="prod-3d9phfMH"><emu-nt id="_ref_24192"><a href="text-processing.html#prod-CharacterClassEscape">CharacterClassEscape</a></emu-nt></emu-rhs>
|
||
</emu-production>
|
||
</emu-grammar>
|
||
<emu-alg><ol><li>Return <emu-val>true</emu-val>.</li></ol></emu-alg>
|
||
</emu-clause>
|
||
|
||
<emu-clause id="sec-patterns-static-semantics-character-value" type="sdo" aoid="CharacterValue">
|
||
<h1><span class="secnum">22.2.1.7</span> Static Semantics: CharacterValue</h1>
|
||
<p>The <emu-xref href="#sec-algorithm-conventions-syntax-directed-operations" id="_ref_11686"><a href="notational-conventions.html#sec-algorithm-conventions-syntax-directed-operations">syntax-directed operation</a></emu-xref> CharacterValue takes no arguments and returns a non-negative <emu-xref href="#integer" id="_ref_11687"><a href="notational-conventions.html#integer">integer</a></emu-xref>.</p>
|
||
<emu-note><span class="note">Note 1</span><div class="note-contents">
|
||
<p>This section is amended in <emu-xref href="#sec-patterns-static-semantics-character-value-annexb" id="_ref_684"><a href="additional-ecmascript-features-for-web-browsers.html#sec-patterns-static-semantics-character-value-annexb">B.1.2.4</a></emu-xref>.</p>
|
||
</div></emu-note>
|
||
<p>It is defined piecewise over the following productions:</p>
|
||
<emu-grammar><emu-production name="ClassAtom" type="lexical" collapsed="">
|
||
<emu-nt><a href="text-processing.html#prod-ClassAtom">ClassAtom</a></emu-nt> <emu-geq>::</emu-geq> <emu-rhs a="byslh4l8" id="prod-xjk33vk0"><emu-t>-</emu-t></emu-rhs>
|
||
</emu-production>
|
||
</emu-grammar>
|
||
<emu-alg><ol><li>Return the numeric value of U+002D (HYPHEN-MINUS).</li></ol></emu-alg>
|
||
<emu-grammar><emu-production name="ClassAtomNoDash" type="lexical" collapsed="">
|
||
<emu-nt><a href="text-processing.html#prod-ClassAtomNoDash">ClassAtomNoDash</a></emu-nt> <emu-geq>::</emu-geq> <emu-rhs a="7n5ukjeb" id="prod-r7Whzgyd"><emu-nt id="_ref_24193"><a href="ecmascript-language-source-code.html#prod-SourceCharacter">SourceCharacter</a></emu-nt> <emu-gmod>but not one of <emu-t>\</emu-t> or <emu-t>]</emu-t> or <emu-t>-</emu-t></emu-gmod></emu-rhs>
|
||
</emu-production>
|
||
</emu-grammar>
|
||
<emu-alg><ol><li>Let <var>ch</var> be the code point matched by <emu-nt id="_ref_24194"><a href="ecmascript-language-source-code.html#prod-SourceCharacter">SourceCharacter</a></emu-nt>.</li><li>Return the numeric value of <var>ch</var>.</li></ol></emu-alg>
|
||
<emu-grammar><emu-production name="ClassEscape" type="lexical" collapsed="">
|
||
<emu-nt><a href="text-processing.html#prod-ClassEscape">ClassEscape</a></emu-nt> <emu-geq>::</emu-geq> <emu-rhs a="ayxoiyyq" id="prod-lioRfUCB"><emu-t>b</emu-t></emu-rhs>
|
||
</emu-production>
|
||
</emu-grammar>
|
||
<emu-alg><ol><li>Return the numeric value of U+0008 (BACKSPACE).</li></ol></emu-alg>
|
||
<emu-grammar><emu-production name="ClassEscape" type="lexical" collapsed="">
|
||
<emu-nt><a href="text-processing.html#prod-ClassEscape">ClassEscape</a></emu-nt> <emu-geq>::</emu-geq> <emu-rhs a="byslh4l8" id="prod-RssYfbc0"><emu-t>-</emu-t></emu-rhs>
|
||
</emu-production>
|
||
</emu-grammar>
|
||
<emu-alg><ol><li>Return the numeric value of U+002D (HYPHEN-MINUS).</li></ol></emu-alg>
|
||
<emu-grammar><emu-production name="CharacterEscape" type="lexical" collapsed="">
|
||
<emu-nt><a href="text-processing.html#prod-CharacterEscape">CharacterEscape</a></emu-nt> <emu-geq>::</emu-geq> <emu-rhs a="-i5xcal8" id="prod-qdZp22xs"><emu-nt id="_ref_24195"><a href="text-processing.html#prod-ControlEscape">ControlEscape</a></emu-nt></emu-rhs>
|
||
</emu-production>
|
||
</emu-grammar>
|
||
<emu-alg><ol><li>Return the numeric value according to <emu-xref href="#table-controlescape-code-point-values" id="_ref_685"><a href="text-processing.html#table-controlescape-code-point-values">Table 62</a></emu-xref>.</li></ol></emu-alg>
|
||
<emu-table id="table-controlescape-code-point-values" caption="ControlEscape Code Point Values" oldids="table-47"><figure><figcaption>Table 62: ControlEscape Code Point Values</figcaption><span id="table-47"></span>
|
||
<table>
|
||
<thead>
|
||
<tr>
|
||
<th>
|
||
ControlEscape
|
||
</th>
|
||
<th>
|
||
Numeric Value
|
||
</th>
|
||
<th>
|
||
Code Point
|
||
</th>
|
||
<th>
|
||
Unicode Name
|
||
</th>
|
||
<th>
|
||
Symbol
|
||
</th>
|
||
</tr>
|
||
</thead>
|
||
<tbody><tr>
|
||
<td>
|
||
<code>t</code>
|
||
</td>
|
||
<td>
|
||
9
|
||
</td>
|
||
<td>
|
||
<code>U+0009</code>
|
||
</td>
|
||
<td>
|
||
CHARACTER TABULATION
|
||
</td>
|
||
<td>
|
||
<HT>
|
||
</td>
|
||
</tr>
|
||
<tr>
|
||
<td>
|
||
<code>n</code>
|
||
</td>
|
||
<td>
|
||
10
|
||
</td>
|
||
<td>
|
||
<code>U+000A</code>
|
||
</td>
|
||
<td>
|
||
LINE FEED (LF)
|
||
</td>
|
||
<td>
|
||
<LF>
|
||
</td>
|
||
</tr>
|
||
<tr>
|
||
<td>
|
||
<code>v</code>
|
||
</td>
|
||
<td>
|
||
11
|
||
</td>
|
||
<td>
|
||
<code>U+000B</code>
|
||
</td>
|
||
<td>
|
||
LINE TABULATION
|
||
</td>
|
||
<td>
|
||
<VT>
|
||
</td>
|
||
</tr>
|
||
<tr>
|
||
<td>
|
||
<code>f</code>
|
||
</td>
|
||
<td>
|
||
12
|
||
</td>
|
||
<td>
|
||
<code>U+000C</code>
|
||
</td>
|
||
<td>
|
||
FORM FEED (FF)
|
||
</td>
|
||
<td>
|
||
<FF>
|
||
</td>
|
||
</tr>
|
||
<tr>
|
||
<td>
|
||
<code>r</code>
|
||
</td>
|
||
<td>
|
||
13
|
||
</td>
|
||
<td>
|
||
<code>U+000D</code>
|
||
</td>
|
||
<td>
|
||
CARRIAGE RETURN (CR)
|
||
</td>
|
||
<td>
|
||
<CR>
|
||
</td>
|
||
</tr>
|
||
</tbody></table>
|
||
</figure></emu-table>
|
||
<emu-grammar><emu-production name="CharacterEscape" type="lexical" collapsed="">
|
||
<emu-nt><a href="text-processing.html#prod-CharacterEscape">CharacterEscape</a></emu-nt> <emu-geq>::</emu-geq> <emu-rhs a="lf4h7vn-" id="prod-OO2zEPPr">
|
||
<emu-t>c</emu-t>
|
||
<emu-nt id="_ref_24196"><a href="ecmascript-language-lexical-grammar.html#prod-AsciiLetter">AsciiLetter</a></emu-nt>
|
||
</emu-rhs>
|
||
</emu-production>
|
||
</emu-grammar>
|
||
<emu-alg><ol><li>Let <var>ch</var> be the code point matched by <emu-nt id="_ref_24197"><a href="ecmascript-language-lexical-grammar.html#prod-AsciiLetter">AsciiLetter</a></emu-nt>.</li><li>Let <var>i</var> be the numeric value of <var>ch</var>.</li><li>Return the remainder of dividing <var>i</var> by 32.</li></ol></emu-alg>
|
||
<emu-grammar><emu-production name="CharacterEscape" type="lexical" collapsed="">
|
||
<emu-nt><a href="text-processing.html#prod-CharacterEscape">CharacterEscape</a></emu-nt> <emu-geq>::</emu-geq> <emu-rhs a="br2d94cy" id="prod--h1KYMFX">
|
||
<emu-t>0</emu-t>
|
||
<emu-gann>[lookahead ∉ <emu-nt id="_ref_24198"><a href="ecmascript-language-lexical-grammar.html#prod-DecimalDigit">DecimalDigit</a></emu-nt>]</emu-gann>
|
||
</emu-rhs>
|
||
</emu-production>
|
||
</emu-grammar>
|
||
<emu-alg><ol><li>Return the numeric value of U+0000 (NULL).</li></ol></emu-alg>
|
||
<emu-note><span class="note">Note 2</span><div class="note-contents">
|
||
<p><code>\0</code> represents the <NUL> character and cannot be followed by a decimal digit.</p>
|
||
</div></emu-note>
|
||
<emu-grammar><emu-production name="CharacterEscape" type="lexical" collapsed="">
|
||
<emu-nt><a href="text-processing.html#prod-CharacterEscape">CharacterEscape</a></emu-nt> <emu-geq>::</emu-geq> <emu-rhs a="qacbhaps" id="prod-GXRVwMQi"><emu-nt id="_ref_24199"><a href="ecmascript-language-lexical-grammar.html#prod-HexEscapeSequence">HexEscapeSequence</a></emu-nt></emu-rhs>
|
||
</emu-production>
|
||
</emu-grammar>
|
||
<emu-alg><ol><li>Return the MV of <emu-nt id="_ref_24200"><a href="ecmascript-language-lexical-grammar.html#prod-HexEscapeSequence">HexEscapeSequence</a></emu-nt>.</li></ol></emu-alg>
|
||
<emu-grammar><emu-production name="RegExpUnicodeEscapeSequence" type="lexical" collapsed="">
|
||
<emu-nt><a href="text-processing.html#prod-RegExpUnicodeEscapeSequence">RegExpUnicodeEscapeSequence</a></emu-nt> <emu-geq>::</emu-geq> <emu-rhs a="nr7lnrwo" id="prod-xQFw7WMV">
|
||
<emu-t>u</emu-t>
|
||
<emu-nt id="_ref_24201"><a href="text-processing.html#prod-HexLeadSurrogate">HexLeadSurrogate</a></emu-nt>
|
||
<emu-t>\u</emu-t>
|
||
<emu-nt id="_ref_24202"><a href="text-processing.html#prod-HexTrailSurrogate">HexTrailSurrogate</a></emu-nt>
|
||
</emu-rhs>
|
||
</emu-production>
|
||
</emu-grammar>
|
||
<emu-alg><ol><li>Let <var>lead</var> be the <emu-xref aoid="CharacterValue" id="_ref_11688"><a href="text-processing.html#sec-patterns-static-semantics-character-value">CharacterValue</a></emu-xref> of <emu-nt id="_ref_24203"><a href="text-processing.html#prod-HexLeadSurrogate">HexLeadSurrogate</a></emu-nt>.</li><li>Let <var>trail</var> be the <emu-xref aoid="CharacterValue" id="_ref_11689"><a href="text-processing.html#sec-patterns-static-semantics-character-value">CharacterValue</a></emu-xref> of <emu-nt id="_ref_24204"><a href="text-processing.html#prod-HexTrailSurrogate">HexTrailSurrogate</a></emu-nt>.</li><li>Let <var>cp</var> be <emu-xref aoid="UTF16SurrogatePairToCodePoint" id="_ref_11690"><a href="ecmascript-language-source-code.html#sec-utf16decodesurrogatepair">UTF16SurrogatePairToCodePoint</a></emu-xref>(<var>lead</var>, <var>trail</var>).</li><li>Return the numeric value of <var>cp</var>.</li></ol></emu-alg>
|
||
<emu-grammar><emu-production name="RegExpUnicodeEscapeSequence" type="lexical" collapsed="">
|
||
<emu-nt><a href="text-processing.html#prod-RegExpUnicodeEscapeSequence">RegExpUnicodeEscapeSequence</a></emu-nt> <emu-geq>::</emu-geq> <emu-rhs a="ghktjvoi" id="prod-OI8ASjmd">
|
||
<emu-t>u</emu-t>
|
||
<emu-nt id="_ref_24205"><a href="ecmascript-language-lexical-grammar.html#prod-Hex4Digits">Hex4Digits</a></emu-nt>
|
||
</emu-rhs>
|
||
</emu-production>
|
||
</emu-grammar>
|
||
<emu-alg><ol><li>Return the MV of <emu-nt id="_ref_24206"><a href="ecmascript-language-lexical-grammar.html#prod-Hex4Digits">Hex4Digits</a></emu-nt>.</li></ol></emu-alg>
|
||
<emu-grammar><emu-production name="RegExpUnicodeEscapeSequence" type="lexical" collapsed="">
|
||
<emu-nt><a href="text-processing.html#prod-RegExpUnicodeEscapeSequence">RegExpUnicodeEscapeSequence</a></emu-nt> <emu-geq>::</emu-geq> <emu-rhs a="uybj7_dt" id="prod-cC4Huuek">
|
||
<emu-t>u{</emu-t>
|
||
<emu-nt id="_ref_24207"><a href="ecmascript-language-lexical-grammar.html#prod-CodePoint">CodePoint</a></emu-nt>
|
||
<emu-t>}</emu-t>
|
||
</emu-rhs>
|
||
</emu-production>
|
||
</emu-grammar>
|
||
<emu-alg><ol><li>Return the MV of <emu-nt id="_ref_24208"><a href="ecmascript-language-lexical-grammar.html#prod-CodePoint">CodePoint</a></emu-nt>.</li></ol></emu-alg>
|
||
<emu-grammar><emu-production name="HexLeadSurrogate" type="lexical" collapsed="">
|
||
<emu-nt><a href="text-processing.html#prod-HexLeadSurrogate">HexLeadSurrogate</a></emu-nt> <emu-geq>::</emu-geq> <emu-rhs a="pptelolr" id="prod-KB9TwXt5"><emu-nt id="_ref_24209"><a href="ecmascript-language-lexical-grammar.html#prod-Hex4Digits">Hex4Digits</a></emu-nt></emu-rhs>
|
||
</emu-production>
|
||
<emu-production name="HexTrailSurrogate" type="lexical" collapsed="">
|
||
<emu-nt><a href="text-processing.html#prod-HexTrailSurrogate">HexTrailSurrogate</a></emu-nt> <emu-geq>::</emu-geq> <emu-rhs a="pptelolr" id="prod-w_eLE8Wq"><emu-nt id="_ref_24210"><a href="ecmascript-language-lexical-grammar.html#prod-Hex4Digits">Hex4Digits</a></emu-nt></emu-rhs>
|
||
</emu-production>
|
||
<emu-production name="HexNonSurrogate" type="lexical" collapsed="">
|
||
<emu-nt><a href="text-processing.html#prod-HexNonSurrogate">HexNonSurrogate</a></emu-nt> <emu-geq>::</emu-geq> <emu-rhs a="pptelolr" id="prod-gm_vpVWn"><emu-nt id="_ref_24211"><a href="ecmascript-language-lexical-grammar.html#prod-Hex4Digits">Hex4Digits</a></emu-nt></emu-rhs>
|
||
</emu-production>
|
||
</emu-grammar>
|
||
<emu-alg><ol><li>Return the MV of <emu-nt id="_ref_24212"><a href="ecmascript-language-lexical-grammar.html#prod-Hex4Digits">Hex4Digits</a></emu-nt>.</li></ol></emu-alg>
|
||
<emu-grammar><emu-production name="CharacterEscape" type="lexical" collapsed="">
|
||
<emu-nt><a href="text-processing.html#prod-CharacterEscape">CharacterEscape</a></emu-nt> <emu-geq>::</emu-geq> <emu-rhs a="ge9cjxqz" id="prod-u6hqoUgl"><emu-nt id="_ref_24213"><a href="text-processing.html#prod-IdentityEscape">IdentityEscape</a></emu-nt></emu-rhs>
|
||
</emu-production>
|
||
</emu-grammar>
|
||
<emu-alg><ol><li>Let <var>ch</var> be the code point matched by <emu-nt id="_ref_24214"><a href="text-processing.html#prod-IdentityEscape">IdentityEscape</a></emu-nt>.</li><li>Return the numeric value of <var>ch</var>.</li></ol></emu-alg>
|
||
<emu-grammar><emu-production name="ClassSetCharacter" type="lexical" collapsed="">
|
||
<emu-nt><a href="text-processing.html#prod-ClassSetCharacter">ClassSetCharacter</a></emu-nt> <emu-geq>::</emu-geq> <emu-rhs a="kyrub20l" id="prod-dwcLz84m"><emu-nt id="_ref_24215"><a href="ecmascript-language-source-code.html#prod-SourceCharacter">SourceCharacter</a></emu-nt> <emu-gmod>but not <emu-nt id="_ref_24216"><a href="text-processing.html#prod-ClassSetSyntaxCharacter">ClassSetSyntaxCharacter</a></emu-nt></emu-gmod></emu-rhs>
|
||
</emu-production>
|
||
</emu-grammar>
|
||
<emu-alg><ol><li>Let <var>ch</var> be the code point matched by <emu-nt id="_ref_24217"><a href="ecmascript-language-source-code.html#prod-SourceCharacter">SourceCharacter</a></emu-nt>.</li><li>Return the numeric value of <var>ch</var>.</li></ol></emu-alg>
|
||
<emu-grammar><emu-production name="ClassSetCharacter" type="lexical" collapsed="">
|
||
<emu-nt><a href="text-processing.html#prod-ClassSetCharacter">ClassSetCharacter</a></emu-nt> <emu-geq>::</emu-geq> <emu-rhs a="xyoixwqd" id="prod-y0BubLe1">
|
||
<emu-t>\</emu-t>
|
||
<emu-nt id="_ref_24218"><a href="text-processing.html#prod-ClassSetReservedPunctuator">ClassSetReservedPunctuator</a></emu-nt>
|
||
</emu-rhs>
|
||
</emu-production>
|
||
</emu-grammar>
|
||
<emu-alg><ol><li>Let <var>ch</var> be the code point matched by <emu-nt id="_ref_24219"><a href="text-processing.html#prod-ClassSetReservedPunctuator">ClassSetReservedPunctuator</a></emu-nt>.</li><li>Return the numeric value of <var>ch</var>.</li></ol></emu-alg>
|
||
<emu-grammar><emu-production name="ClassSetCharacter" type="lexical" collapsed="">
|
||
<emu-nt><a href="text-processing.html#prod-ClassSetCharacter">ClassSetCharacter</a></emu-nt> <emu-geq>::</emu-geq> <emu-rhs a="axxsqknu" id="prod-VNuih8IG"><emu-t>\b</emu-t></emu-rhs>
|
||
</emu-production>
|
||
</emu-grammar>
|
||
<emu-alg><ol><li>Return the numeric value of U+0008 (BACKSPACE).</li></ol></emu-alg>
|
||
</emu-clause>
|
||
|
||
<emu-clause id="sec-static-semantics-maycontainstrings" type="sdo" aoid="MayContainStrings">
|
||
<h1><span class="secnum">22.2.1.8</span> Static Semantics: MayContainStrings</h1>
|
||
<p>The <emu-xref href="#sec-algorithm-conventions-syntax-directed-operations" id="_ref_11691"><a href="notational-conventions.html#sec-algorithm-conventions-syntax-directed-operations">syntax-directed operation</a></emu-xref> MayContainStrings takes no arguments and returns a Boolean. It is defined piecewise over the following productions:</p>
|
||
<emu-grammar><emu-production name="CharacterClassEscape" type="lexical">
|
||
<emu-nt><a href="text-processing.html#prod-CharacterClassEscape">CharacterClassEscape</a></emu-nt> <emu-geq>::</emu-geq> <emu-rhs a="8pmnkw2i" id="prod-Bf6PNBQl">
|
||
<emu-t>d</emu-t>
|
||
</emu-rhs>
|
||
<emu-rhs a="kzsugx0d" id="prod-RGVe7d_l">
|
||
<emu-t>D</emu-t>
|
||
</emu-rhs>
|
||
<emu-rhs a="w5xsbsk3" id="prod-OqQUZ1AJ">
|
||
<emu-t>s</emu-t>
|
||
</emu-rhs>
|
||
<emu-rhs a="avlpsekd" id="prod-wOKKYLJh">
|
||
<emu-t>S</emu-t>
|
||
</emu-rhs>
|
||
<emu-rhs a="lytism1a" id="prod-f1pS245L">
|
||
<emu-t>w</emu-t>
|
||
</emu-rhs>
|
||
<emu-rhs a="rhxouzu-" id="prod-GFqiLy7V">
|
||
<emu-t>W</emu-t>
|
||
</emu-rhs>
|
||
<emu-rhs a="4og7ke5v" id="prod-RmQZ0iW5">
|
||
<emu-t>P{</emu-t>
|
||
<emu-nt id="_ref_24220"><a href="text-processing.html#prod-UnicodePropertyValueExpression">UnicodePropertyValueExpression</a></emu-nt>
|
||
<emu-t>}</emu-t>
|
||
</emu-rhs>
|
||
</emu-production>
|
||
<emu-production name="UnicodePropertyValueExpression" type="lexical">
|
||
<emu-nt><a href="text-processing.html#prod-UnicodePropertyValueExpression">UnicodePropertyValueExpression</a></emu-nt> <emu-geq>::</emu-geq> <emu-rhs a="sr3kbwzj" id="prod-s2EbLfVa">
|
||
<emu-nt id="_ref_24221"><a href="text-processing.html#prod-UnicodePropertyName">UnicodePropertyName</a></emu-nt>
|
||
<emu-t>=</emu-t>
|
||
<emu-nt id="_ref_24222"><a href="text-processing.html#prod-UnicodePropertyValue">UnicodePropertyValue</a></emu-nt>
|
||
</emu-rhs>
|
||
</emu-production>
|
||
<emu-production name="NestedClass" type="lexical">
|
||
<emu-nt><a href="text-processing.html#prod-NestedClass">NestedClass</a></emu-nt> <emu-geq>::</emu-geq> <emu-rhs a="d-swr39f" id="prod-KPMY0hl9">
|
||
<emu-t>[^</emu-t>
|
||
<emu-nt id="_ref_24223"><a href="text-processing.html#prod-ClassContents">ClassContents</a></emu-nt>
|
||
<emu-t>]</emu-t>
|
||
</emu-rhs>
|
||
</emu-production>
|
||
<emu-production name="ClassContents" type="lexical">
|
||
<emu-nt><a href="text-processing.html#prod-ClassContents">ClassContents</a></emu-nt> <emu-geq>::</emu-geq> <emu-rhs a="n7nathbb" id="prod-mJSrJEIb">
|
||
<emu-gann>[empty]</emu-gann>
|
||
</emu-rhs>
|
||
<emu-rhs a="t0au2wo3" id="prod-VIFWQA3E">
|
||
<emu-nt id="_ref_24224"><a href="text-processing.html#prod-NonemptyClassRanges">NonemptyClassRanges</a></emu-nt>
|
||
</emu-rhs>
|
||
</emu-production>
|
||
<emu-production name="ClassSetOperand" type="lexical">
|
||
<emu-nt><a href="text-processing.html#prod-ClassSetOperand">ClassSetOperand</a></emu-nt> <emu-geq>::</emu-geq> <emu-rhs a="pbrz9y58" id="prod-fXQDqqMu">
|
||
<emu-nt id="_ref_24225"><a href="text-processing.html#prod-ClassSetCharacter">ClassSetCharacter</a></emu-nt>
|
||
</emu-rhs>
|
||
</emu-production>
|
||
</emu-grammar>
|
||
<emu-alg><ol><li>Return <emu-val>false</emu-val>.</li></ol></emu-alg>
|
||
<emu-grammar><emu-production name="UnicodePropertyValueExpression" type="lexical" collapsed="">
|
||
<emu-nt><a href="text-processing.html#prod-UnicodePropertyValueExpression">UnicodePropertyValueExpression</a></emu-nt> <emu-geq>::</emu-geq> <emu-rhs a="jdlbklv9" id="prod-Vo8Rxe-U"><emu-nt id="_ref_24226"><a href="text-processing.html#prod-LoneUnicodePropertyNameOrValue">LoneUnicodePropertyNameOrValue</a></emu-nt></emu-rhs>
|
||
</emu-production>
|
||
</emu-grammar>
|
||
<emu-alg><ol><li>If the <emu-xref href="#sec-algorithm-conventions-syntax-directed-operations" id="_ref_11692"><a href="notational-conventions.html#sec-algorithm-conventions-syntax-directed-operations">source text matched by</a></emu-xref> <emu-nt id="_ref_24227"><a href="text-processing.html#prod-LoneUnicodePropertyNameOrValue">LoneUnicodePropertyNameOrValue</a></emu-nt> is a binary property of strings listed in the “<emu-not-ref>Property name</emu-not-ref>” column of <emu-xref href="#table-binary-unicode-properties-of-strings" id="_ref_686"><a href="text-processing.html#table-binary-unicode-properties-of-strings">Table 66</a></emu-xref>, return <emu-val>true</emu-val>.</li><li>Return <emu-val>false</emu-val>.</li></ol></emu-alg>
|
||
<emu-grammar><emu-production name="ClassUnion" type="lexical" collapsed="">
|
||
<emu-nt><a href="text-processing.html#prod-ClassUnion">ClassUnion</a></emu-nt> <emu-geq>::</emu-geq> <emu-rhs a="lvavyv54" id="prod-gvGJSfuv">
|
||
<emu-nt id="_ref_24228"><a href="text-processing.html#prod-ClassSetRange">ClassSetRange</a></emu-nt>
|
||
<emu-nt optional="" id="_ref_24229"><a href="text-processing.html#prod-ClassUnion">ClassUnion</a><emu-mods><emu-opt>opt</emu-opt></emu-mods></emu-nt>
|
||
</emu-rhs>
|
||
</emu-production>
|
||
</emu-grammar>
|
||
<emu-alg><ol><li>If the <emu-nt id="_ref_24230"><a href="text-processing.html#prod-ClassUnion">ClassUnion</a></emu-nt> is present, return <emu-xref aoid="MayContainStrings" id="_ref_11693"><a href="text-processing.html#sec-static-semantics-maycontainstrings">MayContainStrings</a></emu-xref> of the <emu-nt id="_ref_24231"><a href="text-processing.html#prod-ClassUnion">ClassUnion</a></emu-nt>.</li><li>Return <emu-val>false</emu-val>.</li></ol></emu-alg>
|
||
<emu-grammar><emu-production name="ClassUnion" type="lexical" collapsed="">
|
||
<emu-nt><a href="text-processing.html#prod-ClassUnion">ClassUnion</a></emu-nt> <emu-geq>::</emu-geq> <emu-rhs a="ga57bqew" id="prod-sW7TOMGn">
|
||
<emu-nt id="_ref_24232"><a href="text-processing.html#prod-ClassSetOperand">ClassSetOperand</a></emu-nt>
|
||
<emu-nt optional="" id="_ref_24233"><a href="text-processing.html#prod-ClassUnion">ClassUnion</a><emu-mods><emu-opt>opt</emu-opt></emu-mods></emu-nt>
|
||
</emu-rhs>
|
||
</emu-production>
|
||
</emu-grammar>
|
||
<emu-alg><ol><li>If <emu-xref aoid="MayContainStrings" id="_ref_11694"><a href="text-processing.html#sec-static-semantics-maycontainstrings">MayContainStrings</a></emu-xref> of the <emu-nt id="_ref_24234"><a href="text-processing.html#prod-ClassSetOperand">ClassSetOperand</a></emu-nt> is <emu-val>true</emu-val>, return <emu-val>true</emu-val>.</li><li>If <emu-nt id="_ref_24235"><a href="text-processing.html#prod-ClassUnion">ClassUnion</a></emu-nt> is present, return <emu-xref aoid="MayContainStrings" id="_ref_11695"><a href="text-processing.html#sec-static-semantics-maycontainstrings">MayContainStrings</a></emu-xref> of the <emu-nt id="_ref_24236"><a href="text-processing.html#prod-ClassUnion">ClassUnion</a></emu-nt>.</li><li>Return <emu-val>false</emu-val>.</li></ol></emu-alg>
|
||
<emu-grammar><emu-production name="ClassIntersection" type="lexical" collapsed="">
|
||
<emu-nt><a href="text-processing.html#prod-ClassIntersection">ClassIntersection</a></emu-nt> <emu-geq>::</emu-geq> <emu-rhs a="ldjtuyxs" id="prod-kLr2Lu9G">
|
||
<emu-nt id="_ref_24237"><a href="text-processing.html#prod-ClassSetOperand">ClassSetOperand</a></emu-nt>
|
||
<emu-t>&&</emu-t>
|
||
<emu-nt id="_ref_24238"><a href="text-processing.html#prod-ClassSetOperand">ClassSetOperand</a></emu-nt>
|
||
</emu-rhs>
|
||
</emu-production>
|
||
</emu-grammar>
|
||
<emu-alg><ol><li>If <emu-xref aoid="MayContainStrings" id="_ref_11696"><a href="text-processing.html#sec-static-semantics-maycontainstrings">MayContainStrings</a></emu-xref> of the first <emu-nt id="_ref_24239"><a href="text-processing.html#prod-ClassSetOperand">ClassSetOperand</a></emu-nt> is <emu-val>false</emu-val>, return <emu-val>false</emu-val>.</li><li>If <emu-xref aoid="MayContainStrings" id="_ref_11697"><a href="text-processing.html#sec-static-semantics-maycontainstrings">MayContainStrings</a></emu-xref> of the second <emu-nt id="_ref_24240"><a href="text-processing.html#prod-ClassSetOperand">ClassSetOperand</a></emu-nt> is <emu-val>false</emu-val>, return <emu-val>false</emu-val>.</li><li>Return <emu-val>true</emu-val>.</li></ol></emu-alg>
|
||
<emu-grammar><emu-production name="ClassIntersection" type="lexical" collapsed="">
|
||
<emu-nt><a href="text-processing.html#prod-ClassIntersection">ClassIntersection</a></emu-nt> <emu-geq>::</emu-geq> <emu-rhs a="sqaogagb" id="prod-TP89l0-Y">
|
||
<emu-nt id="_ref_24241"><a href="text-processing.html#prod-ClassIntersection">ClassIntersection</a></emu-nt>
|
||
<emu-t>&&</emu-t>
|
||
<emu-nt id="_ref_24242"><a href="text-processing.html#prod-ClassSetOperand">ClassSetOperand</a></emu-nt>
|
||
</emu-rhs>
|
||
</emu-production>
|
||
</emu-grammar>
|
||
<emu-alg><ol><li>If <emu-xref aoid="MayContainStrings" id="_ref_11698"><a href="text-processing.html#sec-static-semantics-maycontainstrings">MayContainStrings</a></emu-xref> of the <emu-nt id="_ref_24243"><a href="text-processing.html#prod-ClassIntersection">ClassIntersection</a></emu-nt> is <emu-val>false</emu-val>, return <emu-val>false</emu-val>.</li><li>If <emu-xref aoid="MayContainStrings" id="_ref_11699"><a href="text-processing.html#sec-static-semantics-maycontainstrings">MayContainStrings</a></emu-xref> of the <emu-nt id="_ref_24244"><a href="text-processing.html#prod-ClassSetOperand">ClassSetOperand</a></emu-nt> is <emu-val>false</emu-val>, return <emu-val>false</emu-val>.</li><li>Return <emu-val>true</emu-val>.</li></ol></emu-alg>
|
||
<emu-grammar><emu-production name="ClassSubtraction" type="lexical" collapsed="">
|
||
<emu-nt><a href="text-processing.html#prod-ClassSubtraction">ClassSubtraction</a></emu-nt> <emu-geq>::</emu-geq> <emu-rhs a="0iwjxoz1" id="prod-tcMmJV95">
|
||
<emu-nt id="_ref_24245"><a href="text-processing.html#prod-ClassSetOperand">ClassSetOperand</a></emu-nt>
|
||
<emu-t>--</emu-t>
|
||
<emu-nt id="_ref_24246"><a href="text-processing.html#prod-ClassSetOperand">ClassSetOperand</a></emu-nt>
|
||
</emu-rhs>
|
||
</emu-production>
|
||
</emu-grammar>
|
||
<emu-alg><ol><li>Return <emu-xref aoid="MayContainStrings" id="_ref_11700"><a href="text-processing.html#sec-static-semantics-maycontainstrings">MayContainStrings</a></emu-xref> of the first <emu-nt id="_ref_24247"><a href="text-processing.html#prod-ClassSetOperand">ClassSetOperand</a></emu-nt>.</li></ol></emu-alg>
|
||
<emu-grammar><emu-production name="ClassSubtraction" type="lexical" collapsed="">
|
||
<emu-nt><a href="text-processing.html#prod-ClassSubtraction">ClassSubtraction</a></emu-nt> <emu-geq>::</emu-geq> <emu-rhs a="pdtgdxpo" id="prod-vhe5K8uN">
|
||
<emu-nt id="_ref_24248"><a href="text-processing.html#prod-ClassSubtraction">ClassSubtraction</a></emu-nt>
|
||
<emu-t>--</emu-t>
|
||
<emu-nt id="_ref_24249"><a href="text-processing.html#prod-ClassSetOperand">ClassSetOperand</a></emu-nt>
|
||
</emu-rhs>
|
||
</emu-production>
|
||
</emu-grammar>
|
||
<emu-alg><ol><li>Return <emu-xref aoid="MayContainStrings" id="_ref_11701"><a href="text-processing.html#sec-static-semantics-maycontainstrings">MayContainStrings</a></emu-xref> of the <emu-nt id="_ref_24250"><a href="text-processing.html#prod-ClassSubtraction">ClassSubtraction</a></emu-nt>.</li></ol></emu-alg>
|
||
<emu-grammar><emu-production name="ClassStringDisjunctionContents" type="lexical" collapsed="">
|
||
<emu-nt><a href="text-processing.html#prod-ClassStringDisjunctionContents">ClassStringDisjunctionContents</a></emu-nt> <emu-geq>::</emu-geq> <emu-rhs a="bsmwgovm" id="prod-2TGoIgN5">
|
||
<emu-nt id="_ref_24251"><a href="text-processing.html#prod-ClassString">ClassString</a></emu-nt>
|
||
<emu-t>|</emu-t>
|
||
<emu-nt id="_ref_24252"><a href="text-processing.html#prod-ClassStringDisjunctionContents">ClassStringDisjunctionContents</a></emu-nt>
|
||
</emu-rhs>
|
||
</emu-production>
|
||
</emu-grammar>
|
||
<emu-alg><ol><li>If <emu-xref aoid="MayContainStrings" id="_ref_11702"><a href="text-processing.html#sec-static-semantics-maycontainstrings">MayContainStrings</a></emu-xref> of the <emu-nt id="_ref_24253"><a href="text-processing.html#prod-ClassString">ClassString</a></emu-nt> is <emu-val>true</emu-val>, return <emu-val>true</emu-val>.</li><li>Return <emu-xref aoid="MayContainStrings" id="_ref_11703"><a href="text-processing.html#sec-static-semantics-maycontainstrings">MayContainStrings</a></emu-xref> of the <emu-nt id="_ref_24254"><a href="text-processing.html#prod-ClassStringDisjunctionContents">ClassStringDisjunctionContents</a></emu-nt>.</li></ol></emu-alg>
|
||
<emu-grammar><emu-production name="ClassString" type="lexical" collapsed="">
|
||
<emu-nt><a href="text-processing.html#prod-ClassString">ClassString</a></emu-nt> <emu-geq>::</emu-geq> <emu-rhs a="n7nathbb" id="prod-5vHBhYYk"><emu-gann>[empty]</emu-gann></emu-rhs>
|
||
</emu-production>
|
||
</emu-grammar>
|
||
<emu-alg><ol><li>Return <emu-val>true</emu-val>.</li></ol></emu-alg>
|
||
<emu-grammar><emu-production name="ClassString" type="lexical" collapsed="">
|
||
<emu-nt><a href="text-processing.html#prod-ClassString">ClassString</a></emu-nt> <emu-geq>::</emu-geq> <emu-rhs a="zzzearnw" id="prod-Cx8VwpMk"><emu-nt id="_ref_24255"><a href="text-processing.html#prod-NonEmptyClassString">NonEmptyClassString</a></emu-nt></emu-rhs>
|
||
</emu-production>
|
||
</emu-grammar>
|
||
<emu-alg><ol><li>Return <emu-xref aoid="MayContainStrings" id="_ref_11704"><a href="text-processing.html#sec-static-semantics-maycontainstrings">MayContainStrings</a></emu-xref> of the <emu-nt id="_ref_24256"><a href="text-processing.html#prod-NonEmptyClassString">NonEmptyClassString</a></emu-nt>.</li></ol></emu-alg>
|
||
<emu-grammar><emu-production name="NonEmptyClassString" type="lexical" collapsed="">
|
||
<emu-nt><a href="text-processing.html#prod-NonEmptyClassString">NonEmptyClassString</a></emu-nt> <emu-geq>::</emu-geq> <emu-rhs a="g-kpie7v" id="prod-w1OPLko-">
|
||
<emu-nt id="_ref_24257"><a href="text-processing.html#prod-ClassSetCharacter">ClassSetCharacter</a></emu-nt>
|
||
<emu-nt optional="" id="_ref_24258"><a href="text-processing.html#prod-NonEmptyClassString">NonEmptyClassString</a><emu-mods><emu-opt>opt</emu-opt></emu-mods></emu-nt>
|
||
</emu-rhs>
|
||
</emu-production>
|
||
</emu-grammar>
|
||
<emu-alg><ol><li>If <emu-nt id="_ref_24259"><a href="text-processing.html#prod-NonEmptyClassString">NonEmptyClassString</a></emu-nt> is present, return <emu-val>true</emu-val>.</li><li>Return <emu-val>false</emu-val>.</li></ol></emu-alg>
|
||
</emu-clause>
|
||
|
||
<emu-clause id="sec-groupspecifiersthatmatch" type="abstract operation" aoid="GroupSpecifiersThatMatch">
|
||
<h1><span class="secnum">22.2.1.9</span> Static Semantics: GroupSpecifiersThatMatch ( <var>thisGroupName</var> )</h1>
|
||
<p>The abstract operation GroupSpecifiersThatMatch takes argument <var>thisGroupName</var> (a <emu-nt id="_ref_24260"><a href="text-processing.html#prod-GroupName">GroupName</a></emu-nt> <emu-xref href="#sec-syntactic-grammar" id="_ref_11705"><a href="notational-conventions.html#sec-syntactic-grammar">Parse Node</a></emu-xref>) and returns a <emu-xref href="#sec-list-and-record-specification-type" id="_ref_11706"><a href="ecmascript-data-types-and-values.html#sec-list-and-record-specification-type">List</a></emu-xref> of <emu-nt id="_ref_24261"><a href="text-processing.html#prod-GroupSpecifier">GroupSpecifier</a></emu-nt> <emu-xref href="#sec-syntactic-grammar" id="_ref_11707"><a href="notational-conventions.html#sec-syntactic-grammar">Parse Nodes</a></emu-xref>. It performs the following steps when called:</p>
|
||
<emu-alg><ol><li>Let <var>name</var> be the <emu-xref aoid="CapturingGroupName" id="_ref_11708"><a href="text-processing.html#sec-static-semantics-capturinggroupname">CapturingGroupName</a></emu-xref> of <var>thisGroupName</var>.</li><li>Let <var>pattern</var> be the <emu-nt id="_ref_24262"><a href="text-processing.html#prod-Pattern">Pattern</a></emu-nt> containing <var>thisGroupName</var>.</li><li>Let <var>result</var> be a new empty <emu-xref href="#sec-list-and-record-specification-type" id="_ref_11709"><a href="ecmascript-data-types-and-values.html#sec-list-and-record-specification-type">List</a></emu-xref>.</li><li>For each <emu-nt id="_ref_24263"><a href="text-processing.html#prod-GroupSpecifier">GroupSpecifier</a></emu-nt> <var>gs</var> that <var>pattern</var> contains, do<ol><li>If the <emu-xref aoid="CapturingGroupName" id="_ref_11710"><a href="text-processing.html#sec-static-semantics-capturinggroupname">CapturingGroupName</a></emu-xref> of <var>gs</var> is <var>name</var>, then<ol><li>Append <var>gs</var> to <var>result</var>.</li></ol></li></ol></li><li>Return <var>result</var>.</li></ol></emu-alg>
|
||
</emu-clause>
|
||
|
||
<emu-clause id="sec-static-semantics-capturinggroupname" oldids="sec-regexp-identifier-names-static-semantics-stringvalue" type="sdo" aoid="CapturingGroupName"><span id="sec-regexp-identifier-names-static-semantics-stringvalue"></span>
|
||
<h1><span class="secnum">22.2.1.10</span> Static Semantics: CapturingGroupName</h1>
|
||
<p>The <emu-xref href="#sec-algorithm-conventions-syntax-directed-operations" id="_ref_11711"><a href="notational-conventions.html#sec-algorithm-conventions-syntax-directed-operations">syntax-directed operation</a></emu-xref> CapturingGroupName takes no arguments and returns a String. It is defined piecewise over the following productions:</p>
|
||
<emu-grammar><emu-production name="GroupName" type="lexical" collapsed="">
|
||
<emu-nt><a href="text-processing.html#prod-GroupName">GroupName</a></emu-nt> <emu-geq>::</emu-geq> <emu-rhs a="ibpwjayv" id="prod-n_is87x3">
|
||
<emu-t><</emu-t>
|
||
<emu-nt id="_ref_24264"><a href="text-processing.html#prod-RegExpIdentifierName">RegExpIdentifierName</a></emu-nt>
|
||
<emu-t>></emu-t>
|
||
</emu-rhs>
|
||
</emu-production>
|
||
</emu-grammar>
|
||
<emu-alg><ol><li>Let <var>idTextUnescaped</var> be the <emu-xref aoid="RegExpIdentifierCodePoints" id="_ref_11712"><a href="text-processing.html#sec-regexpidentifiercodepoints">RegExpIdentifierCodePoints</a></emu-xref> of <emu-nt id="_ref_24265"><a href="text-processing.html#prod-RegExpIdentifierName">RegExpIdentifierName</a></emu-nt>.</li><li>Return <emu-xref aoid="CodePointsToString" id="_ref_11713"><a href="ecmascript-language-source-code.html#sec-codepointstostring">CodePointsToString</a></emu-xref>(<var>idTextUnescaped</var>).</li></ol></emu-alg>
|
||
</emu-clause>
|
||
|
||
<emu-clause id="sec-regexpidentifiercodepoints" type="sdo" aoid="RegExpIdentifierCodePoints">
|
||
<h1><span class="secnum">22.2.1.11</span> Static Semantics: RegExpIdentifierCodePoints</h1>
|
||
<p>The <emu-xref href="#sec-algorithm-conventions-syntax-directed-operations" id="_ref_11714"><a href="notational-conventions.html#sec-algorithm-conventions-syntax-directed-operations">syntax-directed operation</a></emu-xref> RegExpIdentifierCodePoints takes no arguments and returns a <emu-xref href="#sec-list-and-record-specification-type" id="_ref_11715"><a href="ecmascript-data-types-and-values.html#sec-list-and-record-specification-type">List</a></emu-xref> of code points. It is defined piecewise over the following productions:</p>
|
||
<emu-grammar><emu-production name="RegExpIdentifierName" type="lexical" collapsed="">
|
||
<emu-nt><a href="text-processing.html#prod-RegExpIdentifierName">RegExpIdentifierName</a></emu-nt> <emu-geq>::</emu-geq> <emu-rhs a="0tblzef_" id="prod-MLgOzB7a"><emu-nt id="_ref_24266"><a href="text-processing.html#prod-RegExpIdentifierStart">RegExpIdentifierStart</a></emu-nt></emu-rhs>
|
||
</emu-production>
|
||
</emu-grammar>
|
||
<emu-alg><ol><li>Let <var>cp</var> be the <emu-xref aoid="RegExpIdentifierCodePoint" id="_ref_11716"><a href="text-processing.html#sec-regexpidentifiercodepoint">RegExpIdentifierCodePoint</a></emu-xref> of <emu-nt id="_ref_24267"><a href="text-processing.html#prod-RegExpIdentifierStart">RegExpIdentifierStart</a></emu-nt>.</li><li>Return « <var>cp</var> ».</li></ol></emu-alg>
|
||
<emu-grammar><emu-production name="RegExpIdentifierName" type="lexical" collapsed="">
|
||
<emu-nt><a href="text-processing.html#prod-RegExpIdentifierName">RegExpIdentifierName</a></emu-nt> <emu-geq>::</emu-geq> <emu-rhs a="tpc7qkeo" id="prod-s0FAcATI">
|
||
<emu-nt id="_ref_24268"><a href="text-processing.html#prod-RegExpIdentifierName">RegExpIdentifierName</a></emu-nt>
|
||
<emu-nt id="_ref_24269"><a href="text-processing.html#prod-RegExpIdentifierPart">RegExpIdentifierPart</a></emu-nt>
|
||
</emu-rhs>
|
||
</emu-production>
|
||
</emu-grammar>
|
||
<emu-alg><ol><li>Let <var>cps</var> be the <emu-xref aoid="RegExpIdentifierCodePoints" id="_ref_11717"><a href="text-processing.html#sec-regexpidentifiercodepoints">RegExpIdentifierCodePoints</a></emu-xref> of the derived <emu-nt id="_ref_24270"><a href="text-processing.html#prod-RegExpIdentifierName">RegExpIdentifierName</a></emu-nt>.</li><li>Let <var>cp</var> be the <emu-xref aoid="RegExpIdentifierCodePoint" id="_ref_11718"><a href="text-processing.html#sec-regexpidentifiercodepoint">RegExpIdentifierCodePoint</a></emu-xref> of <emu-nt id="_ref_24271"><a href="text-processing.html#prod-RegExpIdentifierPart">RegExpIdentifierPart</a></emu-nt>.</li><li>Return the <emu-xref href="#list-concatenation" id="_ref_11719"><a href="ecmascript-data-types-and-values.html#list-concatenation">list-concatenation</a></emu-xref> of <var>cps</var> and « <var>cp</var> ».</li></ol></emu-alg>
|
||
</emu-clause>
|
||
|
||
<emu-clause id="sec-regexpidentifiercodepoint" type="sdo" aoid="RegExpIdentifierCodePoint">
|
||
<h1><span class="secnum">22.2.1.12</span> Static Semantics: RegExpIdentifierCodePoint</h1>
|
||
<p>The <emu-xref href="#sec-algorithm-conventions-syntax-directed-operations" id="_ref_11720"><a href="notational-conventions.html#sec-algorithm-conventions-syntax-directed-operations">syntax-directed operation</a></emu-xref> RegExpIdentifierCodePoint takes no arguments and returns a code point. It is defined piecewise over the following productions:</p>
|
||
<emu-grammar><emu-production name="RegExpIdentifierStart" type="lexical" collapsed="">
|
||
<emu-nt><a href="text-processing.html#prod-RegExpIdentifierStart">RegExpIdentifierStart</a></emu-nt> <emu-geq>::</emu-geq> <emu-rhs a="scjzw6a_" id="prod-KawRYiQy"><emu-nt id="_ref_24272"><a href="ecmascript-language-lexical-grammar.html#prod-IdentifierStartChar">IdentifierStartChar</a></emu-nt></emu-rhs>
|
||
</emu-production>
|
||
</emu-grammar>
|
||
<emu-alg><ol><li>Return the code point matched by <emu-nt id="_ref_24273"><a href="ecmascript-language-lexical-grammar.html#prod-IdentifierStartChar">IdentifierStartChar</a></emu-nt>.</li></ol></emu-alg>
|
||
<emu-grammar><emu-production name="RegExpIdentifierPart" type="lexical" collapsed="">
|
||
<emu-nt><a href="text-processing.html#prod-RegExpIdentifierPart">RegExpIdentifierPart</a></emu-nt> <emu-geq>::</emu-geq> <emu-rhs a="q3hdl-qt" id="prod-hbCPVPTo"><emu-nt id="_ref_24274"><a href="ecmascript-language-lexical-grammar.html#prod-IdentifierPartChar">IdentifierPartChar</a></emu-nt></emu-rhs>
|
||
</emu-production>
|
||
</emu-grammar>
|
||
<emu-alg><ol><li>Return the code point matched by <emu-nt id="_ref_24275"><a href="ecmascript-language-lexical-grammar.html#prod-IdentifierPartChar">IdentifierPartChar</a></emu-nt>.</li></ol></emu-alg>
|
||
<emu-grammar><emu-production name="RegExpIdentifierStart" type="lexical" collapsed="">
|
||
<emu-nt><a href="text-processing.html#prod-RegExpIdentifierStart">RegExpIdentifierStart</a></emu-nt> <emu-geq>::</emu-geq> <emu-rhs a="vkfrbm2v" id="prod-3xUUqpuD">
|
||
<emu-t>\</emu-t>
|
||
<emu-nt id="_ref_24276"><a href="text-processing.html#prod-RegExpUnicodeEscapeSequence">RegExpUnicodeEscapeSequence</a></emu-nt>
|
||
</emu-rhs>
|
||
</emu-production>
|
||
<emu-production name="RegExpIdentifierPart" type="lexical" collapsed="">
|
||
<emu-nt><a href="text-processing.html#prod-RegExpIdentifierPart">RegExpIdentifierPart</a></emu-nt> <emu-geq>::</emu-geq> <emu-rhs a="vkfrbm2v" id="prod-qsRdhrnd">
|
||
<emu-t>\</emu-t>
|
||
<emu-nt id="_ref_24277"><a href="text-processing.html#prod-RegExpUnicodeEscapeSequence">RegExpUnicodeEscapeSequence</a></emu-nt>
|
||
</emu-rhs>
|
||
</emu-production>
|
||
</emu-grammar>
|
||
<emu-alg><ol><li>Return the code point whose numeric value is the <emu-xref aoid="CharacterValue" id="_ref_11721"><a href="text-processing.html#sec-patterns-static-semantics-character-value">CharacterValue</a></emu-xref> of <emu-nt id="_ref_24278"><a href="text-processing.html#prod-RegExpUnicodeEscapeSequence">RegExpUnicodeEscapeSequence</a></emu-nt>.</li></ol></emu-alg>
|
||
<emu-grammar><emu-production name="RegExpIdentifierStart" type="lexical" collapsed="">
|
||
<emu-nt><a href="text-processing.html#prod-RegExpIdentifierStart">RegExpIdentifierStart</a></emu-nt> <emu-geq>::</emu-geq> <emu-rhs a="-hbnr2gv" id="prod-rk-_SuFT">
|
||
<emu-nt id="_ref_24279"><a href="text-processing.html#prod-UnicodeLeadSurrogate">UnicodeLeadSurrogate</a></emu-nt>
|
||
<emu-nt id="_ref_24280"><a href="text-processing.html#prod-UnicodeTrailSurrogate">UnicodeTrailSurrogate</a></emu-nt>
|
||
</emu-rhs>
|
||
</emu-production>
|
||
<emu-production name="RegExpIdentifierPart" type="lexical" collapsed="">
|
||
<emu-nt><a href="text-processing.html#prod-RegExpIdentifierPart">RegExpIdentifierPart</a></emu-nt> <emu-geq>::</emu-geq> <emu-rhs a="-hbnr2gv" id="prod-NowIa6nU">
|
||
<emu-nt id="_ref_24281"><a href="text-processing.html#prod-UnicodeLeadSurrogate">UnicodeLeadSurrogate</a></emu-nt>
|
||
<emu-nt id="_ref_24282"><a href="text-processing.html#prod-UnicodeTrailSurrogate">UnicodeTrailSurrogate</a></emu-nt>
|
||
</emu-rhs>
|
||
</emu-production>
|
||
</emu-grammar>
|
||
<emu-alg><ol><li>Let <var>lead</var> be the code unit whose numeric value is the numeric value of the code point matched by <emu-nt id="_ref_24283"><a href="text-processing.html#prod-UnicodeLeadSurrogate">UnicodeLeadSurrogate</a></emu-nt>.</li><li>Let <var>trail</var> be the code unit whose numeric value is the numeric value of the code point matched by <emu-nt id="_ref_24284"><a href="text-processing.html#prod-UnicodeTrailSurrogate">UnicodeTrailSurrogate</a></emu-nt>.</li><li>Return <emu-xref aoid="UTF16SurrogatePairToCodePoint" id="_ref_11722"><a href="ecmascript-language-source-code.html#sec-utf16decodesurrogatepair">UTF16SurrogatePairToCodePoint</a></emu-xref>(<var>lead</var>, <var>trail</var>).</li></ol></emu-alg>
|
||
</emu-clause>
|
||
</emu-clause>
|
||
|
||
<emu-clause id="sec-pattern-semantics">
|
||
<h1><span class="secnum">22.2.2</span> Pattern Semantics</h1>
|
||
<p>A regular expression pattern is converted into an <emu-xref href="#sec-abstract-closure" id="_ref_11723"><a href="ecmascript-data-types-and-values.html#sec-abstract-closure">Abstract Closure</a></emu-xref> using the process described below. An implementation is encouraged to use more efficient algorithms than the ones listed below, as long as the results are the same. The <emu-xref href="#sec-abstract-closure" id="_ref_11724"><a href="ecmascript-data-types-and-values.html#sec-abstract-closure">Abstract Closure</a></emu-xref> is used as the value of a RegExp object's <var class="field">[[RegExpMatcher]]</var> internal slot.</p>
|
||
<p>A <emu-nt id="_ref_24285"><a href="text-processing.html#prod-Pattern">Pattern</a></emu-nt> is a BMP pattern if its associated flags contain neither a <code>u</code> nor a <code>v</code>. Otherwise, it is a Unicode pattern. A BMP pattern matches against a String interpreted as consisting of a sequence of 16-bit values that are Unicode code points in the range of the Basic Multilingual Plane. A Unicode pattern matches against a String interpreted as consisting of Unicode code points encoded using UTF-16. In the context of describing the behaviour of a BMP pattern “character” means a single 16-bit Unicode BMP code point. In the context of describing the behaviour of a Unicode pattern “character” means a UTF-16 encoded code point (<emu-xref href="#sec-ecmascript-language-types-string-type" id="_ref_687"><a href="ecmascript-data-types-and-values.html#sec-ecmascript-language-types-string-type">6.1.4</a></emu-xref>). In either context, “character value” means the numeric value of the corresponding non-encoded code point.</p>
|
||
<p>The syntax and semantics of <emu-nt id="_ref_24286"><a href="text-processing.html#prod-Pattern">Pattern</a></emu-nt> is defined as if the source text for the <emu-nt id="_ref_24287"><a href="text-processing.html#prod-Pattern">Pattern</a></emu-nt> was a <emu-xref href="#sec-list-and-record-specification-type" id="_ref_11725"><a href="ecmascript-data-types-and-values.html#sec-list-and-record-specification-type">List</a></emu-xref> of <emu-nt id="_ref_24288"><a href="ecmascript-language-source-code.html#prod-SourceCharacter">SourceCharacter</a></emu-nt> values where each <emu-nt id="_ref_24289"><a href="ecmascript-language-source-code.html#prod-SourceCharacter">SourceCharacter</a></emu-nt> corresponds to a Unicode code point. If a BMP pattern contains a non-BMP <emu-nt id="_ref_24290"><a href="ecmascript-language-source-code.html#prod-SourceCharacter">SourceCharacter</a></emu-nt> the entire pattern is encoded using UTF-16 and the individual code units of that encoding are used as the elements of the <emu-xref href="#sec-list-and-record-specification-type" id="_ref_11726"><a href="ecmascript-data-types-and-values.html#sec-list-and-record-specification-type">List</a></emu-xref>.</p>
|
||
<emu-note><span class="note">Note</span><div class="note-contents">
|
||
<p>For example, consider a pattern expressed in source text as the single non-BMP character U+1D11E (MUSICAL SYMBOL G CLEF). Interpreted as a Unicode pattern, it would be a single element (character) <emu-xref href="#sec-list-and-record-specification-type" id="_ref_11727"><a href="ecmascript-data-types-and-values.html#sec-list-and-record-specification-type">List</a></emu-xref> consisting of the single code point U+1D11E. However, interpreted as a BMP pattern, it is first UTF-16 encoded to produce a two element <emu-xref href="#sec-list-and-record-specification-type" id="_ref_11728"><a href="ecmascript-data-types-and-values.html#sec-list-and-record-specification-type">List</a></emu-xref> consisting of the code units 0xD834 and 0xDD1E.</p>
|
||
<p>Patterns are passed to the RegExp <emu-xref href="#constructor" id="_ref_11729"><a href="ecmascript-data-types-and-values.html#constructor">constructor</a></emu-xref> as ECMAScript String values in which non-BMP characters are UTF-16 encoded. For example, the single character MUSICAL SYMBOL G CLEF pattern, expressed as a String value, <emu-xref href="#sec-ecmascript-language-types-string-type" id="_ref_11730"><a href="ecmascript-data-types-and-values.html#sec-ecmascript-language-types-string-type">is a String</a></emu-xref> of length 2 whose elements were the code units 0xD834 and 0xDD1E. So no further translation of the string would be necessary to process it as a BMP pattern consisting of two pattern characters. However, to process it as a Unicode pattern <emu-xref aoid="UTF16SurrogatePairToCodePoint" id="_ref_11731"><a href="ecmascript-language-source-code.html#sec-utf16decodesurrogatepair">UTF16SurrogatePairToCodePoint</a></emu-xref> must be used in producing a <emu-xref href="#sec-list-and-record-specification-type" id="_ref_11732"><a href="ecmascript-data-types-and-values.html#sec-list-and-record-specification-type">List</a></emu-xref> whose sole element is a single pattern character, the code point U+1D11E.</p>
|
||
<p>An implementation may not actually perform such translations to or from UTF-16, but the semantics of this specification requires that the result of pattern matching be as if such translations were performed.</p>
|
||
</div></emu-note>
|
||
|
||
<emu-clause id="sec-pattern-notation" oldids="sec-notation"><span id="sec-notation"></span>
|
||
<h1><span class="secnum">22.2.2.1</span> Notation</h1>
|
||
<p>The descriptions below use the following internal data structures:</p>
|
||
<ul>
|
||
<li>
|
||
A <dfn tabindex="-1">CharSetElement</dfn> is one of the two following entities:
|
||
<ul>
|
||
<li>
|
||
If <var>rer</var>.<var class="field">[[UnicodeSets]]</var> is <emu-val>false</emu-val>, then a CharSetElement is a character in the sense of the Pattern Semantics above.
|
||
</li>
|
||
<li>
|
||
If <var>rer</var>.<var class="field">[[UnicodeSets]]</var> is <emu-val>true</emu-val>, then a CharSetElement is a sequence whose elements are characters in the sense of the Pattern Semantics above. This includes the empty sequence, sequences of one character, and sequences of more than one character. For convenience, when working with CharSetElements of this kind, an individual character is treated interchangeably with a sequence of one character.
|
||
</li>
|
||
</ul>
|
||
</li>
|
||
<li>
|
||
A <dfn id="pattern-charset" variants="CharSets" tabindex="-1">CharSet</dfn> is a mathematical set of CharSetElements.
|
||
</li>
|
||
<li>
|
||
A <dfn id="pattern-capturerange" variants="CaptureRanges" tabindex="-1">CaptureRange</dfn> is a <emu-xref href="#sec-list-and-record-specification-type" id="_ref_11733"><a href="ecmascript-data-types-and-values.html#sec-list-and-record-specification-type">Record</a></emu-xref> { <var class="field">[[StartIndex]]</var>, <var class="field">[[EndIndex]]</var> } that represents the range of characters included in a capture, where <var class="field">[[StartIndex]]</var> is an <emu-xref href="#integer" id="_ref_11734"><a href="notational-conventions.html#integer">integer</a></emu-xref> representing the start index (inclusive) of the range within <var>Input</var>, and <var class="field">[[EndIndex]]</var> is an <emu-xref href="#integer" id="_ref_11735"><a href="notational-conventions.html#integer">integer</a></emu-xref> representing the end index (exclusive) of the range within <var>Input</var>. For any <emu-xref href="#pattern-capturerange" id="_ref_11736"><a href="text-processing.html#pattern-capturerange">CaptureRange</a></emu-xref>, these indices must satisfy the invariant that <var class="field">[[StartIndex]]</var> ≤ <var class="field">[[EndIndex]]</var>.
|
||
</li>
|
||
<li>
|
||
A <dfn id="pattern-matchstate" variants="MatchStates" oldids="pattern-matchresult" tabindex="-1"><span id="pattern-matchresult"></span>MatchState</dfn> is a <emu-xref href="#sec-list-and-record-specification-type" id="_ref_11737"><a href="ecmascript-data-types-and-values.html#sec-list-and-record-specification-type">Record</a></emu-xref> { <var class="field">[[Input]]</var>, <var class="field">[[EndIndex]]</var>, <var class="field">[[Captures]]</var> } where <var class="field">[[Input]]</var> is a <emu-xref href="#sec-list-and-record-specification-type" id="_ref_11738"><a href="ecmascript-data-types-and-values.html#sec-list-and-record-specification-type">List</a></emu-xref> of characters representing the String being matched, <var class="field">[[EndIndex]]</var> is an <emu-xref href="#integer" id="_ref_11739"><a href="notational-conventions.html#integer">integer</a></emu-xref>, and <var class="field">[[Captures]]</var> is a <emu-xref href="#sec-list-and-record-specification-type" id="_ref_11740"><a href="ecmascript-data-types-and-values.html#sec-list-and-record-specification-type">List</a></emu-xref> of values, one for each <emu-xref href="#sec-countleftcapturingparenswithin" id="_ref_11741"><a href="text-processing.html#sec-countleftcapturingparenswithin">left-capturing parenthesis</a></emu-xref> in the pattern. <emu-xref href="#pattern-matchstate" id="_ref_11742"><a href="text-processing.html#pattern-matchstate">MatchStates</a></emu-xref> are used to represent partial match states in the regular expression matching algorithms. The <var class="field">[[EndIndex]]</var> is one plus the index of the last input character matched so far by the pattern, while <var class="field">[[Captures]]</var> holds the results of capturing parentheses. The <var>n</var><sup>th</sup> element of <var class="field">[[Captures]]</var> is either a <emu-xref href="#pattern-capturerange" id="_ref_11743"><a href="text-processing.html#pattern-capturerange">CaptureRange</a></emu-xref> representing the range of characters captured by the <var>n</var><sup>th</sup> set of capturing parentheses, or <emu-val>undefined</emu-val> if the <var>n</var><sup>th</sup> set of capturing parentheses hasn't been reached yet. Due to backtracking, many <emu-xref href="#pattern-matchstate" id="_ref_11744"><a href="text-processing.html#pattern-matchstate">MatchStates</a></emu-xref> may be in use at any time during the matching process.
|
||
</li>
|
||
<li>
|
||
A <dfn id="pattern-matchercontinuation" variants="MatcherContinuations" tabindex="-1">MatcherContinuation</dfn> is an <emu-xref href="#sec-abstract-closure" id="_ref_11745"><a href="ecmascript-data-types-and-values.html#sec-abstract-closure">Abstract Closure</a></emu-xref> that takes one <emu-xref href="#pattern-matchstate" id="_ref_11746"><a href="text-processing.html#pattern-matchstate">MatchState</a></emu-xref> argument and returns either a <emu-xref href="#pattern-matchstate" id="_ref_11747"><a href="text-processing.html#pattern-matchstate">MatchState</a></emu-xref> or <emu-const>failure</emu-const>. The <emu-xref href="#pattern-matchercontinuation" id="_ref_11748"><a href="text-processing.html#pattern-matchercontinuation">MatcherContinuation</a></emu-xref> attempts to match the remaining portion (specified by the closure's captured values) of the pattern against <var>Input</var>, starting at the intermediate state given by its <emu-xref href="#pattern-matchstate" id="_ref_11749"><a href="text-processing.html#pattern-matchstate">MatchState</a></emu-xref> argument. If the match succeeds, the <emu-xref href="#pattern-matchercontinuation" id="_ref_11750"><a href="text-processing.html#pattern-matchercontinuation">MatcherContinuation</a></emu-xref> returns the final <emu-xref href="#pattern-matchstate" id="_ref_11751"><a href="text-processing.html#pattern-matchstate">MatchState</a></emu-xref> that it reached; if the match fails, the <emu-xref href="#pattern-matchercontinuation" id="_ref_11752"><a href="text-processing.html#pattern-matchercontinuation">MatcherContinuation</a></emu-xref> returns <emu-const>failure</emu-const>.
|
||
</li>
|
||
<li>
|
||
A <dfn id="pattern-matcher" variants="Matchers" tabindex="-1">Matcher</dfn> is an <emu-xref href="#sec-abstract-closure" id="_ref_11753"><a href="ecmascript-data-types-and-values.html#sec-abstract-closure">Abstract Closure</a></emu-xref> that takes two arguments—a <emu-xref href="#pattern-matchstate" id="_ref_11754"><a href="text-processing.html#pattern-matchstate">MatchState</a></emu-xref> and a <emu-xref href="#pattern-matchercontinuation" id="_ref_11755"><a href="text-processing.html#pattern-matchercontinuation">MatcherContinuation</a></emu-xref>—and returns either a <emu-xref href="#pattern-matchstate" id="_ref_11756"><a href="text-processing.html#pattern-matchstate">MatchState</a></emu-xref> or <emu-const>failure</emu-const>. A <emu-xref href="#pattern-matcher" id="_ref_11757"><a href="text-processing.html#pattern-matcher">Matcher</a></emu-xref> attempts to match a middle subpattern (specified by the closure's captured values) of the pattern against the <emu-xref href="#pattern-matchstate" id="_ref_11758"><a href="text-processing.html#pattern-matchstate">MatchState</a></emu-xref>'s <var class="field">[[Input]]</var>, starting at the intermediate state given by its <emu-xref href="#pattern-matchstate" id="_ref_11759"><a href="text-processing.html#pattern-matchstate">MatchState</a></emu-xref> argument. The <emu-xref href="#pattern-matchercontinuation" id="_ref_11760"><a href="text-processing.html#pattern-matchercontinuation">MatcherContinuation</a></emu-xref> argument should be a closure that matches the rest of the pattern. After matching the subpattern of a pattern to obtain a new <emu-xref href="#pattern-matchstate" id="_ref_11761"><a href="text-processing.html#pattern-matchstate">MatchState</a></emu-xref>, the <emu-xref href="#pattern-matcher" id="_ref_11762"><a href="text-processing.html#pattern-matcher">Matcher</a></emu-xref> then calls <emu-xref href="#pattern-matchercontinuation" id="_ref_11763"><a href="text-processing.html#pattern-matchercontinuation">MatcherContinuation</a></emu-xref> on that new <emu-xref href="#pattern-matchstate" id="_ref_11764"><a href="text-processing.html#pattern-matchstate">MatchState</a></emu-xref> to test if the rest of the pattern can match as well. If it can, the <emu-xref href="#pattern-matcher" id="_ref_11765"><a href="text-processing.html#pattern-matcher">Matcher</a></emu-xref> returns the <emu-xref href="#pattern-matchstate" id="_ref_11766"><a href="text-processing.html#pattern-matchstate">MatchState</a></emu-xref> returned by <emu-xref href="#pattern-matchercontinuation" id="_ref_11767"><a href="text-processing.html#pattern-matchercontinuation">MatcherContinuation</a></emu-xref>; if not, the <emu-xref href="#pattern-matcher" id="_ref_11768"><a href="text-processing.html#pattern-matcher">Matcher</a></emu-xref> may try different choices at its choice points, repeatedly calling <emu-xref href="#pattern-matchercontinuation" id="_ref_11769"><a href="text-processing.html#pattern-matchercontinuation">MatcherContinuation</a></emu-xref> until it either succeeds or all possibilities have been exhausted.
|
||
</li>
|
||
</ul>
|
||
|
||
<emu-clause id="sec-regexp-records">
|
||
<h1><span class="secnum">22.2.2.1.1</span> RegExp Records</h1>
|
||
<p>A <dfn variants="RegExp Records" tabindex="-1">RegExp Record</dfn> is a <emu-xref href="#sec-list-and-record-specification-type" id="_ref_11770"><a href="ecmascript-data-types-and-values.html#sec-list-and-record-specification-type">Record</a></emu-xref> value used to store information about a RegExp that is needed during compilation and possibly during matching.</p>
|
||
<p>It has the following fields:</p>
|
||
<emu-table id="table-regexp-record-fields" caption="RegExp Record Fields"><figure><figcaption>Table 63: <emu-xref href="#sec-regexp-records" id="_ref_11771"><a href="text-processing.html#sec-regexp-records">RegExp Record</a></emu-xref> Fields</figcaption>
|
||
<table>
|
||
<thead>
|
||
<tr>
|
||
<th>Field Name</th>
|
||
<th>Value</th>
|
||
<th>Meaning</th>
|
||
</tr>
|
||
</thead>
|
||
<tbody><tr>
|
||
<td><var class="field">[[IgnoreCase]]</var></td>
|
||
<td>a Boolean</td>
|
||
<td>indicates whether <emu-val>"i"</emu-val> appears in the RegExp's flags</td>
|
||
</tr>
|
||
<tr>
|
||
<td><var class="field">[[Multiline]]</var></td>
|
||
<td>a Boolean</td>
|
||
<td>indicates whether <emu-val>"m"</emu-val> appears in the RegExp's flags</td>
|
||
</tr>
|
||
<tr>
|
||
<td><var class="field">[[DotAll]]</var></td>
|
||
<td>a Boolean</td>
|
||
<td>indicates whether <emu-val>"s"</emu-val> appears in the RegExp's flags</td>
|
||
</tr>
|
||
<tr>
|
||
<td><var class="field">[[Unicode]]</var></td>
|
||
<td>a Boolean</td>
|
||
<td>indicates whether <emu-val>"u"</emu-val> appears in the RegExp's flags</td>
|
||
</tr>
|
||
<tr>
|
||
<td><var class="field">[[UnicodeSets]]</var></td>
|
||
<td>a Boolean</td>
|
||
<td>indicates whether <emu-val>"v"</emu-val> appears in the RegExp's flags</td>
|
||
</tr>
|
||
<tr>
|
||
<td><var class="field">[[CapturingGroupsCount]]</var></td>
|
||
<td>a non-negative <emu-xref href="#integer" id="_ref_11772"><a href="notational-conventions.html#integer">integer</a></emu-xref></td>
|
||
<td>the number of <emu-xref href="#sec-countleftcapturingparenswithin" id="_ref_11773"><a href="text-processing.html#sec-countleftcapturingparenswithin">left-capturing parentheses</a></emu-xref> in the RegExp's pattern</td>
|
||
</tr>
|
||
</tbody></table>
|
||
</figure></emu-table>
|
||
</emu-clause>
|
||
</emu-clause>
|
||
|
||
<emu-clause id="sec-compilepattern" type="sdo" oldids="sec-pattern" aoid="CompilePattern"><span id="sec-pattern"></span>
|
||
<h1><span class="secnum">22.2.2.2</span> Runtime Semantics: CompilePattern</h1>
|
||
<p>The <emu-xref href="#sec-algorithm-conventions-syntax-directed-operations" id="_ref_11774"><a href="notational-conventions.html#sec-algorithm-conventions-syntax-directed-operations">syntax-directed operation</a></emu-xref> CompilePattern takes argument <var>rer</var> (a <emu-xref href="#sec-regexp-records" id="_ref_11775"><a href="text-processing.html#sec-regexp-records">RegExp Record</a></emu-xref>) and returns an <emu-xref href="#sec-abstract-closure" id="_ref_11776"><a href="ecmascript-data-types-and-values.html#sec-abstract-closure">Abstract Closure</a></emu-xref> that takes a <emu-xref href="#sec-list-and-record-specification-type" id="_ref_11777"><a href="ecmascript-data-types-and-values.html#sec-list-and-record-specification-type">List</a></emu-xref> of characters and a non-negative <emu-xref href="#integer" id="_ref_11778"><a href="notational-conventions.html#integer">integer</a></emu-xref> and returns either a <emu-xref href="#pattern-matchstate" id="_ref_11779"><a href="text-processing.html#pattern-matchstate">MatchState</a></emu-xref> or <emu-const>failure</emu-const>. It is defined piecewise over the following productions:</p>
|
||
<emu-grammar><emu-production name="Pattern" type="lexical" collapsed="">
|
||
<emu-nt><a href="text-processing.html#prod-Pattern">Pattern</a></emu-nt> <emu-geq>::</emu-geq> <emu-rhs a="eaw70mcy" id="prod-mHyeO4wo"><emu-nt id="_ref_24291"><a href="text-processing.html#prod-Disjunction">Disjunction</a></emu-nt></emu-rhs>
|
||
</emu-production>
|
||
</emu-grammar>
|
||
<emu-alg><ol><li>Let <var>m</var> be <emu-xref aoid="CompileSubpattern" id="_ref_11780"><a href="text-processing.html#sec-compilesubpattern">CompileSubpattern</a></emu-xref> of <emu-nt id="_ref_24292"><a href="text-processing.html#prod-Disjunction">Disjunction</a></emu-nt> with arguments <var>rer</var> and <emu-const>forward</emu-const>.</li><li>Return a new <emu-xref href="#sec-abstract-closure" id="_ref_11781"><a href="ecmascript-data-types-and-values.html#sec-abstract-closure">Abstract Closure</a></emu-xref> with parameters (<var>Input</var>, <var>index</var>) that captures <var>rer</var> and <var>m</var> and performs the following steps when called:<ol><li><emu-xref href="#assert" id="_ref_11782"><a href="notational-conventions.html#assert">Assert</a></emu-xref>: <var>Input</var> is a <emu-xref href="#sec-list-and-record-specification-type" id="_ref_11783"><a href="ecmascript-data-types-and-values.html#sec-list-and-record-specification-type">List</a></emu-xref> of characters.</li><li><emu-xref href="#assert" id="_ref_11784"><a href="notational-conventions.html#assert">Assert</a></emu-xref>: 0 ≤ <var>index</var> ≤ the number of elements in <var>Input</var>.</li><li>Let <var>c</var> be a new <emu-xref href="#pattern-matchercontinuation" id="_ref_11785"><a href="text-processing.html#pattern-matchercontinuation">MatcherContinuation</a></emu-xref> with parameters (<var>y</var>) that captures nothing and performs the following steps when called:<ol><li><emu-xref href="#assert" id="_ref_11786"><a href="notational-conventions.html#assert">Assert</a></emu-xref>: <var>y</var> is a <emu-xref href="#pattern-matchstate" id="_ref_11787"><a href="text-processing.html#pattern-matchstate">MatchState</a></emu-xref>.</li><li>Return <var>y</var>.</li></ol></li><li>Let <var>cap</var> be a <emu-xref href="#sec-list-and-record-specification-type" id="_ref_11788"><a href="ecmascript-data-types-and-values.html#sec-list-and-record-specification-type">List</a></emu-xref> of <var>rer</var>.<var class="field">[[CapturingGroupsCount]]</var> <emu-val>undefined</emu-val> values, indexed 1 through <var>rer</var>.<var class="field">[[CapturingGroupsCount]]</var>.</li><li>Let <var>x</var> be the <emu-xref href="#pattern-matchstate" id="_ref_11789"><a href="text-processing.html#pattern-matchstate">MatchState</a></emu-xref> { <var class="field">[[Input]]</var>: <var>Input</var>, <var class="field">[[EndIndex]]</var>: <var>index</var>, <var class="field">[[Captures]]</var>: <var>cap</var> }.</li><li>Return <var>m</var>(<var>x</var>, <var>c</var>).</li></ol></li></ol></emu-alg>
|
||
<emu-note><span class="note">Note</span><div class="note-contents">
|
||
<p>A Pattern compiles to an <emu-xref href="#sec-abstract-closure" id="_ref_11790"><a href="ecmascript-data-types-and-values.html#sec-abstract-closure">Abstract Closure</a></emu-xref> value. <emu-xref aoid="RegExpBuiltinExec" id="_ref_11791"><a href="text-processing.html#sec-regexpbuiltinexec">RegExpBuiltinExec</a></emu-xref> can then apply this procedure to a <emu-xref href="#sec-list-and-record-specification-type" id="_ref_11792"><a href="ecmascript-data-types-and-values.html#sec-list-and-record-specification-type">List</a></emu-xref> of characters and an offset within that <emu-xref href="#sec-list-and-record-specification-type" id="_ref_11793"><a href="ecmascript-data-types-and-values.html#sec-list-and-record-specification-type">List</a></emu-xref> to determine whether the pattern would match starting at exactly that offset within the <emu-xref href="#sec-list-and-record-specification-type" id="_ref_11794"><a href="ecmascript-data-types-and-values.html#sec-list-and-record-specification-type">List</a></emu-xref>, and, if it does match, what the values of the capturing parentheses would be. The algorithms in <emu-xref href="#sec-pattern-semantics" id="_ref_688"><a href="text-processing.html#sec-pattern-semantics">22.2.2</a></emu-xref> are designed so that compiling a pattern may throw a <emu-val>SyntaxError</emu-val> exception; on the other hand, once the pattern is successfully compiled, applying the resulting <emu-xref href="#sec-abstract-closure" id="_ref_11795"><a href="ecmascript-data-types-and-values.html#sec-abstract-closure">Abstract Closure</a></emu-xref> to find a match in a <emu-xref href="#sec-list-and-record-specification-type" id="_ref_11796"><a href="ecmascript-data-types-and-values.html#sec-list-and-record-specification-type">List</a></emu-xref> of characters cannot throw an exception (except for any <emu-xref href="#implementation-defined" id="_ref_11797"><a href="overview.html#implementation-defined">implementation-defined</a></emu-xref> exceptions that can occur anywhere such as out-of-memory).</p>
|
||
</div></emu-note>
|
||
</emu-clause>
|
||
|
||
<emu-clause id="sec-compilesubpattern" type="sdo" oldids="sec-disjunction,sec-alternative,sec-term" aoid="CompileSubpattern"><span id="sec-term"></span><span id="sec-alternative"></span><span id="sec-disjunction"></span>
|
||
<h1><span class="secnum">22.2.2.3</span> Runtime Semantics: CompileSubpattern</h1>
|
||
<p>The <emu-xref href="#sec-algorithm-conventions-syntax-directed-operations" id="_ref_11798"><a href="notational-conventions.html#sec-algorithm-conventions-syntax-directed-operations">syntax-directed operation</a></emu-xref> CompileSubpattern takes arguments <var>rer</var> (a <emu-xref href="#sec-regexp-records" id="_ref_11799"><a href="text-processing.html#sec-regexp-records">RegExp Record</a></emu-xref>) and <var>direction</var> (<emu-const>forward</emu-const> or <emu-const>backward</emu-const>) and returns a <emu-xref href="#pattern-matcher" id="_ref_11800"><a href="text-processing.html#pattern-matcher">Matcher</a></emu-xref>.</p>
|
||
<emu-note><span class="note">Note 1</span><div class="note-contents">
|
||
<p>This section is amended in <emu-xref href="#sec-compilesubpattern-annexb" id="_ref_689"><a href="additional-ecmascript-features-for-web-browsers.html#sec-compilesubpattern-annexb">B.1.2.5</a></emu-xref>.</p>
|
||
</div></emu-note>
|
||
|
||
<!-- Disjunction -->
|
||
<p>It is defined piecewise over the following productions:</p>
|
||
<emu-grammar><emu-production name="Disjunction" type="lexical" collapsed="">
|
||
<emu-nt><a href="text-processing.html#prod-Disjunction">Disjunction</a></emu-nt> <emu-geq>::</emu-geq> <emu-rhs a="jt2lba_1" id="prod-y4rdvkKA">
|
||
<emu-nt id="_ref_24293"><a href="text-processing.html#prod-Alternative">Alternative</a></emu-nt>
|
||
<emu-t>|</emu-t>
|
||
<emu-nt id="_ref_24294"><a href="text-processing.html#prod-Disjunction">Disjunction</a></emu-nt>
|
||
</emu-rhs>
|
||
</emu-production>
|
||
</emu-grammar>
|
||
<emu-alg><ol><li>Let <var>m1</var> be <emu-xref aoid="CompileSubpattern" id="_ref_11801"><a href="text-processing.html#sec-compilesubpattern">CompileSubpattern</a></emu-xref> of <emu-nt id="_ref_24295"><a href="text-processing.html#prod-Alternative">Alternative</a></emu-nt> with arguments <var>rer</var> and <var>direction</var>.</li><li>Let <var>m2</var> be <emu-xref aoid="CompileSubpattern" id="_ref_11802"><a href="text-processing.html#sec-compilesubpattern">CompileSubpattern</a></emu-xref> of <emu-nt id="_ref_24296"><a href="text-processing.html#prod-Disjunction">Disjunction</a></emu-nt> with arguments <var>rer</var> and <var>direction</var>.</li><li>Return <emu-xref aoid="MatchTwoAlternatives" id="_ref_11803"><a href="text-processing.html#sec-matchtwoalternatives">MatchTwoAlternatives</a></emu-xref>(<var>m1</var>, <var>m2</var>).</li></ol></emu-alg>
|
||
<emu-note><span class="note">Note 2</span><div class="note-contents">
|
||
<p>The <code>|</code> regular expression operator separates two alternatives. The pattern first tries to match the left <emu-nt id="_ref_24297"><a href="text-processing.html#prod-Alternative">Alternative</a></emu-nt> (followed by the sequel of the regular expression); if it fails, it tries to match the right <emu-nt id="_ref_24298"><a href="text-processing.html#prod-Disjunction">Disjunction</a></emu-nt> (followed by the sequel of the regular expression). If the left <emu-nt id="_ref_24299"><a href="text-processing.html#prod-Alternative">Alternative</a></emu-nt>, the right <emu-nt id="_ref_24300"><a href="text-processing.html#prod-Disjunction">Disjunction</a></emu-nt>, and the sequel all have choice points, all choices in the sequel are tried before moving on to the next choice in the left <emu-nt id="_ref_24301"><a href="text-processing.html#prod-Alternative">Alternative</a></emu-nt>. If choices in the left <emu-nt id="_ref_24302"><a href="text-processing.html#prod-Alternative">Alternative</a></emu-nt> are exhausted, the right <emu-nt id="_ref_24303"><a href="text-processing.html#prod-Disjunction">Disjunction</a></emu-nt> is tried instead of the left <emu-nt id="_ref_24304"><a href="text-processing.html#prod-Alternative">Alternative</a></emu-nt>. Any capturing parentheses inside a portion of the pattern skipped by <code>|</code> produce <emu-val>undefined</emu-val> values instead of Strings. Thus, for example,</p>
|
||
<pre><code class="javascript hljs">/a|ab/.<span class="hljs-title function_">exec</span>(<span class="hljs-string">"abc"</span>)</code></pre>
|
||
<p>returns the result <emu-val>"a"</emu-val> and not <emu-val>"ab"</emu-val>. Moreover,</p>
|
||
<pre><code class="javascript hljs">/((a)|(ab))((c)|(bc))/.<span class="hljs-title function_">exec</span>(<span class="hljs-string">"abc"</span>)</code></pre>
|
||
<p>returns the array</p>
|
||
<pre><code class="javascript hljs">[<span class="hljs-string">"abc"</span>, <span class="hljs-string">"a"</span>, <span class="hljs-string">"a"</span>, <span class="hljs-literal">undefined</span>, <span class="hljs-string">"bc"</span>, <span class="hljs-literal">undefined</span>, <span class="hljs-string">"bc"</span>]</code></pre>
|
||
<p>and not</p>
|
||
<pre><code class="javascript hljs">[<span class="hljs-string">"abc"</span>, <span class="hljs-string">"ab"</span>, <span class="hljs-literal">undefined</span>, <span class="hljs-string">"ab"</span>, <span class="hljs-string">"c"</span>, <span class="hljs-string">"c"</span>, <span class="hljs-literal">undefined</span>]</code></pre>
|
||
<p>The order in which the two alternatives are tried is independent of the value of <var>direction</var>.</p>
|
||
</div></emu-note>
|
||
|
||
<!-- Alternative -->
|
||
<emu-grammar><emu-production name="Alternative" type="lexical" collapsed="">
|
||
<emu-nt><a href="text-processing.html#prod-Alternative">Alternative</a></emu-nt> <emu-geq>::</emu-geq> <emu-rhs a="n7nathbb" id="prod-DxcBBSWc"><emu-gann>[empty]</emu-gann></emu-rhs>
|
||
</emu-production>
|
||
</emu-grammar>
|
||
<emu-alg><ol><li>Return <emu-xref aoid="EmptyMatcher" id="_ref_11804"><a href="text-processing.html#sec-emptymatcher">EmptyMatcher</a></emu-xref>().</li></ol></emu-alg>
|
||
<emu-grammar><emu-production name="Alternative" type="lexical" collapsed="">
|
||
<emu-nt><a href="text-processing.html#prod-Alternative">Alternative</a></emu-nt> <emu-geq>::</emu-geq> <emu-rhs a="vctbprkq" id="prod-fiPiStf_">
|
||
<emu-nt id="_ref_24305"><a href="text-processing.html#prod-Alternative">Alternative</a></emu-nt>
|
||
<emu-nt id="_ref_24306"><a href="text-processing.html#prod-Term">Term</a></emu-nt>
|
||
</emu-rhs>
|
||
</emu-production>
|
||
</emu-grammar>
|
||
<emu-alg><ol><li>Let <var>m1</var> be <emu-xref aoid="CompileSubpattern" id="_ref_11805"><a href="text-processing.html#sec-compilesubpattern">CompileSubpattern</a></emu-xref> of <emu-nt id="_ref_24307"><a href="text-processing.html#prod-Alternative">Alternative</a></emu-nt> with arguments <var>rer</var> and <var>direction</var>.</li><li>Let <var>m2</var> be <emu-xref aoid="CompileSubpattern" id="_ref_11806"><a href="text-processing.html#sec-compilesubpattern">CompileSubpattern</a></emu-xref> of <emu-nt id="_ref_24308"><a href="text-processing.html#prod-Term">Term</a></emu-nt> with arguments <var>rer</var> and <var>direction</var>.</li><li>Return <emu-xref aoid="MatchSequence" id="_ref_11807"><a href="text-processing.html#sec-matchsequence">MatchSequence</a></emu-xref>(<var>m1</var>, <var>m2</var>, <var>direction</var>).</li></ol></emu-alg>
|
||
<emu-note><span class="note">Note 3</span><div class="note-contents">
|
||
<p>Consecutive <emu-nt id="_ref_24309"><a href="text-processing.html#prod-Term">Term</a></emu-nt>s try to simultaneously match consecutive portions of <var>Input</var>. When <var>direction</var> is <emu-const>forward</emu-const>, if the left <emu-nt id="_ref_24310"><a href="text-processing.html#prod-Alternative">Alternative</a></emu-nt>, the right <emu-nt id="_ref_24311"><a href="text-processing.html#prod-Term">Term</a></emu-nt>, and the sequel of the regular expression all have choice points, all choices in the sequel are tried before moving on to the next choice in the right <emu-nt id="_ref_24312"><a href="text-processing.html#prod-Term">Term</a></emu-nt>, and all choices in the right <emu-nt id="_ref_24313"><a href="text-processing.html#prod-Term">Term</a></emu-nt> are tried before moving on to the next choice in the left <emu-nt id="_ref_24314"><a href="text-processing.html#prod-Alternative">Alternative</a></emu-nt>. When <var>direction</var> is <emu-const>backward</emu-const>, the evaluation order of <emu-nt id="_ref_24315"><a href="text-processing.html#prod-Alternative">Alternative</a></emu-nt> and <emu-nt id="_ref_24316"><a href="text-processing.html#prod-Term">Term</a></emu-nt> are reversed.</p>
|
||
</div></emu-note>
|
||
|
||
<!-- Term -->
|
||
<emu-grammar><emu-production name="Term" type="lexical" collapsed="">
|
||
<emu-nt><a href="text-processing.html#prod-Term">Term</a></emu-nt> <emu-geq>::</emu-geq> <emu-rhs a="4d3cub6p" id="prod-tmSpn0_R"><emu-nt id="_ref_24317"><a href="text-processing.html#prod-Assertion">Assertion</a></emu-nt></emu-rhs>
|
||
</emu-production>
|
||
</emu-grammar>
|
||
<emu-alg><ol><li>Return <emu-xref aoid="CompileAssertion" id="_ref_11808"><a href="text-processing.html#sec-compileassertion">CompileAssertion</a></emu-xref> of <emu-nt id="_ref_24318"><a href="text-processing.html#prod-Assertion">Assertion</a></emu-nt> with argument <var>rer</var>.</li></ol></emu-alg>
|
||
<emu-note><span class="note">Note 4</span><div class="note-contents">
|
||
<p>The resulting <emu-xref href="#pattern-matcher" id="_ref_11809"><a href="text-processing.html#pattern-matcher">Matcher</a></emu-xref> is independent of <var>direction</var>.</p>
|
||
</div></emu-note>
|
||
<emu-grammar><emu-production name="Term" type="lexical" collapsed="">
|
||
<emu-nt><a href="text-processing.html#prod-Term">Term</a></emu-nt> <emu-geq>::</emu-geq> <emu-rhs a="qd3tqxbs" id="prod-fNHoehtY"><emu-nt id="_ref_24319"><a href="text-processing.html#prod-Atom">Atom</a></emu-nt></emu-rhs>
|
||
</emu-production>
|
||
</emu-grammar>
|
||
<emu-alg><ol><li>Return <emu-xref aoid="CompileAtom" id="_ref_11810"><a href="text-processing.html#sec-compileatom">CompileAtom</a></emu-xref> of <emu-nt id="_ref_24320"><a href="text-processing.html#prod-Atom">Atom</a></emu-nt> with arguments <var>rer</var> and <var>direction</var>.</li></ol></emu-alg>
|
||
<emu-grammar><emu-production name="Term" type="lexical" collapsed="">
|
||
<emu-nt><a href="text-processing.html#prod-Term">Term</a></emu-nt> <emu-geq>::</emu-geq> <emu-rhs a="rk7qpcwj" id="prod-LaYcA3Qv">
|
||
<emu-nt id="_ref_24321"><a href="text-processing.html#prod-Atom">Atom</a></emu-nt>
|
||
<emu-nt id="_ref_24322"><a href="text-processing.html#prod-Quantifier">Quantifier</a></emu-nt>
|
||
</emu-rhs>
|
||
</emu-production>
|
||
</emu-grammar>
|
||
<emu-alg><ol><li>Let <var>m</var> be <emu-xref aoid="CompileAtom" id="_ref_11811"><a href="text-processing.html#sec-compileatom">CompileAtom</a></emu-xref> of <emu-nt id="_ref_24323"><a href="text-processing.html#prod-Atom">Atom</a></emu-nt> with arguments <var>rer</var> and <var>direction</var>.</li><li>Let <var>q</var> be <emu-xref aoid="CompileQuantifier" id="_ref_11812"><a href="text-processing.html#sec-compilequantifier">CompileQuantifier</a></emu-xref> of <emu-nt id="_ref_24324"><a href="text-processing.html#prod-Quantifier">Quantifier</a></emu-nt>.</li><li><emu-xref href="#assert" id="_ref_11813"><a href="notational-conventions.html#assert">Assert</a></emu-xref>: <var>q</var>.<var class="field">[[Min]]</var> ≤ <var>q</var>.<var class="field">[[Max]]</var>.</li><li>Let <var>parenIndex</var> be <emu-xref aoid="CountLeftCapturingParensBefore" id="_ref_11814"><a href="text-processing.html#sec-countleftcapturingparensbefore">CountLeftCapturingParensBefore</a></emu-xref>(<emu-nt id="_ref_24325"><a href="text-processing.html#prod-Term">Term</a></emu-nt>).</li><li>Let <var>parenCount</var> be <emu-xref aoid="CountLeftCapturingParensWithin" id="_ref_11815"><a href="text-processing.html#sec-countleftcapturingparenswithin">CountLeftCapturingParensWithin</a></emu-xref>(<emu-nt id="_ref_24326"><a href="text-processing.html#prod-Atom">Atom</a></emu-nt>).</li><li>Return a new <emu-xref href="#pattern-matcher" id="_ref_11816"><a href="text-processing.html#pattern-matcher">Matcher</a></emu-xref> with parameters (<var>x</var>, <var>c</var>) that captures <var>m</var>, <var>q</var>, <var>parenIndex</var>, and <var>parenCount</var> and performs the following steps when called:<ol><li><emu-xref href="#assert" id="_ref_11817"><a href="notational-conventions.html#assert">Assert</a></emu-xref>: <var>x</var> is a <emu-xref href="#pattern-matchstate" id="_ref_11818"><a href="text-processing.html#pattern-matchstate">MatchState</a></emu-xref>.</li><li><emu-xref href="#assert" id="_ref_11819"><a href="notational-conventions.html#assert">Assert</a></emu-xref>: <var>c</var> is a <emu-xref href="#pattern-matchercontinuation" id="_ref_11820"><a href="text-processing.html#pattern-matchercontinuation">MatcherContinuation</a></emu-xref>.</li><li>Return <emu-xref aoid="RepeatMatcher" id="_ref_11821"><a href="text-processing.html#sec-runtime-semantics-repeatmatcher-abstract-operation">RepeatMatcher</a></emu-xref>(<var>m</var>, <var>q</var>.<var class="field">[[Min]]</var>, <var>q</var>.<var class="field">[[Max]]</var>, <var>q</var>.<var class="field">[[Greedy]]</var>, <var>x</var>, <var>c</var>, <var>parenIndex</var>, <var>parenCount</var>).</li></ol></li></ol></emu-alg>
|
||
|
||
<emu-clause id="sec-runtime-semantics-repeatmatcher-abstract-operation" type="abstract operation" aoid="RepeatMatcher">
|
||
<h1><span class="secnum">22.2.2.3.1</span> RepeatMatcher ( <var>m</var>, <var>min</var>, <var>max</var>, <var>greedy</var>, <var>x</var>, <var>c</var>, <var>parenIndex</var>, <var>parenCount</var> )</h1>
|
||
<p>The abstract operation RepeatMatcher takes arguments <var>m</var> (a <emu-xref href="#pattern-matcher" id="_ref_11822"><a href="text-processing.html#pattern-matcher">Matcher</a></emu-xref>), <var>min</var> (a non-negative <emu-xref href="#integer" id="_ref_11823"><a href="notational-conventions.html#integer">integer</a></emu-xref>), <var>max</var> (a non-negative <emu-xref href="#integer" id="_ref_11824"><a href="notational-conventions.html#integer">integer</a></emu-xref> or +∞), <var>greedy</var> (a Boolean), <var>x</var> (a <emu-xref href="#pattern-matchstate" id="_ref_11825"><a href="text-processing.html#pattern-matchstate">MatchState</a></emu-xref>), <var>c</var> (a <emu-xref href="#pattern-matchercontinuation" id="_ref_11826"><a href="text-processing.html#pattern-matchercontinuation">MatcherContinuation</a></emu-xref>), <var>parenIndex</var> (a non-negative <emu-xref href="#integer" id="_ref_11827"><a href="notational-conventions.html#integer">integer</a></emu-xref>), and <var>parenCount</var> (a non-negative <emu-xref href="#integer" id="_ref_11828"><a href="notational-conventions.html#integer">integer</a></emu-xref>) and returns either a <emu-xref href="#pattern-matchstate" id="_ref_11829"><a href="text-processing.html#pattern-matchstate">MatchState</a></emu-xref> or <emu-const>failure</emu-const>. It performs the following steps when called:</p>
|
||
<emu-alg><ol><li>If <var>max</var> = 0, return <var>c</var>(<var>x</var>).</li><li>Let <var>d</var> be a new <emu-xref href="#pattern-matchercontinuation" id="_ref_11830"><a href="text-processing.html#pattern-matchercontinuation">MatcherContinuation</a></emu-xref> with parameters (<var>y</var>) that captures <var>m</var>, <var>min</var>, <var>max</var>, <var>greedy</var>, <var>x</var>, <var>c</var>, <var>parenIndex</var>, and <var>parenCount</var> and performs the following steps when called:<ol><li><emu-xref href="#assert" id="_ref_11831"><a href="notational-conventions.html#assert">Assert</a></emu-xref>: <var>y</var> is a <emu-xref href="#pattern-matchstate" id="_ref_11832"><a href="text-processing.html#pattern-matchstate">MatchState</a></emu-xref>.</li><li id="step-repeatmatcher-done">If <var>min</var> = 0 and <var>y</var>.<var class="field">[[EndIndex]]</var> = <var>x</var>.<var class="field">[[EndIndex]]</var>, return <emu-const>failure</emu-const>.</li><li>If <var>min</var> = 0, let <var>min2</var> be 0; else let <var>min2</var> be <var>min</var> - 1.</li><li>If <var>max</var> = +∞, let <var>max2</var> be +∞; else let <var>max2</var> be <var>max</var> - 1.</li><li>Return <emu-xref aoid="RepeatMatcher" id="_ref_11833"><a href="text-processing.html#sec-runtime-semantics-repeatmatcher-abstract-operation">RepeatMatcher</a></emu-xref>(<var>m</var>, <var>min2</var>, <var>max2</var>, <var>greedy</var>, <var>y</var>, <var>c</var>, <var>parenIndex</var>, <var>parenCount</var>).</li></ol></li><li>Let <var>cap</var> be a copy of <var>x</var>.<var class="field">[[Captures]]</var>.</li><li id="step-repeatmatcher-clear-captures">For each <emu-xref href="#integer" id="_ref_11834"><a href="notational-conventions.html#integer">integer</a></emu-xref> <var>k</var> in the <emu-xref href="#inclusive-interval" id="_ref_11835"><a href="notational-conventions.html#inclusive-interval">inclusive interval</a></emu-xref> from <var>parenIndex</var> + 1 to <var>parenIndex</var> + <var>parenCount</var>, set <var>cap</var>[<var>k</var>] to <emu-val>undefined</emu-val>.</li><li>Let <var>Input</var> be <var>x</var>.<var class="field">[[Input]]</var>.</li><li>Let <var>e</var> be <var>x</var>.<var class="field">[[EndIndex]]</var>.</li><li>Let <var>xr</var> be the <emu-xref href="#pattern-matchstate" id="_ref_11836"><a href="text-processing.html#pattern-matchstate">MatchState</a></emu-xref> { <var class="field">[[Input]]</var>: <var>Input</var>, <var class="field">[[EndIndex]]</var>: <var>e</var>, <var class="field">[[Captures]]</var>: <var>cap</var> }.</li><li>If <var>min</var> ≠ 0, return <var>m</var>(<var>xr</var>, <var>d</var>).</li><li>If <var>greedy</var> is <emu-val>false</emu-val>, then<ol><li>Let <var>z</var> be <var>c</var>(<var>x</var>).</li><li>If <var>z</var> is not <emu-const>failure</emu-const>, return <var>z</var>.</li><li>Return <var>m</var>(<var>xr</var>, <var>d</var>).</li></ol></li><li>Let <var>z</var> be <var>m</var>(<var>xr</var>, <var>d</var>).</li><li>If <var>z</var> is not <emu-const>failure</emu-const>, return <var>z</var>.</li><li>Return <var>c</var>(<var>x</var>).</li></ol></emu-alg>
|
||
<emu-note><span class="note">Note 1</span><div class="note-contents">
|
||
<p>An <emu-nt id="_ref_24327"><a href="text-processing.html#prod-Atom">Atom</a></emu-nt> followed by a <emu-nt id="_ref_24328"><a href="text-processing.html#prod-Quantifier">Quantifier</a></emu-nt> is repeated the number of times specified by the <emu-nt id="_ref_24329"><a href="text-processing.html#prod-Quantifier">Quantifier</a></emu-nt>. A <emu-nt id="_ref_24330"><a href="text-processing.html#prod-Quantifier">Quantifier</a></emu-nt> can be non-greedy, in which case the <emu-nt id="_ref_24331"><a href="text-processing.html#prod-Atom">Atom</a></emu-nt> pattern is repeated as few times as possible while still matching the sequel, or it can be greedy, in which case the <emu-nt id="_ref_24332"><a href="text-processing.html#prod-Atom">Atom</a></emu-nt> pattern is repeated as many times as possible while still matching the sequel. The <emu-nt id="_ref_24333"><a href="text-processing.html#prod-Atom">Atom</a></emu-nt> pattern is repeated rather than the input character sequence that it matches, so different repetitions of the <emu-nt id="_ref_24334"><a href="text-processing.html#prod-Atom">Atom</a></emu-nt> can match different input substrings.</p>
|
||
</div></emu-note>
|
||
<emu-note><span class="note">Note 2</span><div class="note-contents">
|
||
<p>If the <emu-nt id="_ref_24335"><a href="text-processing.html#prod-Atom">Atom</a></emu-nt> and the sequel of the regular expression all have choice points, the <emu-nt id="_ref_24336"><a href="text-processing.html#prod-Atom">Atom</a></emu-nt> is first matched as many (or as few, if non-greedy) times as possible. All choices in the sequel are tried before moving on to the next choice in the last repetition of <emu-nt id="_ref_24337"><a href="text-processing.html#prod-Atom">Atom</a></emu-nt>. All choices in the last (n<sup>th</sup>) repetition of <emu-nt id="_ref_24338"><a href="text-processing.html#prod-Atom">Atom</a></emu-nt> are tried before moving on to the next choice in the next-to-last (n - 1)<sup>st</sup> repetition of <emu-nt id="_ref_24339"><a href="text-processing.html#prod-Atom">Atom</a></emu-nt>; at which point it may turn out that more or fewer repetitions of <emu-nt id="_ref_24340"><a href="text-processing.html#prod-Atom">Atom</a></emu-nt> are now possible; these are exhausted (again, starting with either as few or as many as possible) before moving on to the next choice in the (n - 1)<sup>st</sup> repetition of <emu-nt id="_ref_24341"><a href="text-processing.html#prod-Atom">Atom</a></emu-nt> and so on.</p>
|
||
<p>Compare</p>
|
||
<pre><code class="javascript hljs">/a[a-z]{<span class="hljs-number">2</span>,<span class="hljs-number">4</span>}/.<span class="hljs-title function_">exec</span>(<span class="hljs-string">"abcdefghi"</span>)</code></pre>
|
||
<p>which returns <emu-val>"abcde"</emu-val> with</p>
|
||
<pre><code class="javascript hljs">/a[a-z]{<span class="hljs-number">2</span>,<span class="hljs-number">4</span>}?/.<span class="hljs-title function_">exec</span>(<span class="hljs-string">"abcdefghi"</span>)</code></pre>
|
||
<p>which returns <emu-val>"abc"</emu-val>.</p>
|
||
<p>Consider also</p>
|
||
<pre><code class="javascript hljs">/(aa|aabaac|ba|b|c)*/.<span class="hljs-title function_">exec</span>(<span class="hljs-string">"aabaac"</span>)</code></pre>
|
||
<p>which, by the choice point ordering above, returns the array</p>
|
||
<pre><code class="javascript hljs">[<span class="hljs-string">"aaba"</span>, <span class="hljs-string">"ba"</span>]</code></pre>
|
||
<p>and not any of:</p>
|
||
<pre><code class="javascript hljs">[<span class="hljs-string">"aabaac"</span>, <span class="hljs-string">"aabaac"</span>]
|
||
[<span class="hljs-string">"aabaac"</span>, <span class="hljs-string">"c"</span>]</code></pre>
|
||
<p>The above ordering of choice points can be used to write a regular expression that calculates the greatest common divisor of two numbers (represented in unary notation). The following example calculates the gcd of 10 and 15:</p>
|
||
<pre><code class="javascript hljs"><span class="hljs-string">"aaaaaaaaaa,aaaaaaaaaaaaaaa"</span>.<span class="hljs-title function_">replace</span>(<span class="hljs-regexp">/^(a+)\1*,\1+$/</span>, <span class="hljs-string">"$1"</span>)</code></pre>
|
||
<p>which returns the gcd in unary notation <emu-val>"aaaaa"</emu-val>.</p>
|
||
</div></emu-note>
|
||
<emu-note><span class="note">Note 3</span><div class="note-contents">
|
||
<p>Step <emu-xref href="#step-repeatmatcher-clear-captures" id="_ref_690"><a href="text-processing.html#step-repeatmatcher-clear-captures">4</a></emu-xref> of the RepeatMatcher clears <emu-nt id="_ref_24342"><a href="text-processing.html#prod-Atom">Atom</a></emu-nt>'s captures each time <emu-nt id="_ref_24343"><a href="text-processing.html#prod-Atom">Atom</a></emu-nt> is repeated. We can see its behaviour in the regular expression</p>
|
||
<pre><code class="javascript hljs">/(z)((a+)?(b+)?(c))*/.<span class="hljs-title function_">exec</span>(<span class="hljs-string">"zaacbbbcac"</span>)</code></pre>
|
||
<p>which returns the array</p>
|
||
<pre><code class="javascript hljs">[<span class="hljs-string">"zaacbbbcac"</span>, <span class="hljs-string">"z"</span>, <span class="hljs-string">"ac"</span>, <span class="hljs-string">"a"</span>, <span class="hljs-literal">undefined</span>, <span class="hljs-string">"c"</span>]</code></pre>
|
||
<p>and not</p>
|
||
<pre><code class="javascript hljs">[<span class="hljs-string">"zaacbbbcac"</span>, <span class="hljs-string">"z"</span>, <span class="hljs-string">"ac"</span>, <span class="hljs-string">"a"</span>, <span class="hljs-string">"bbb"</span>, <span class="hljs-string">"c"</span>]</code></pre>
|
||
<p>because each iteration of the outermost <code>*</code> clears all captured Strings contained in the quantified <emu-nt id="_ref_24344"><a href="text-processing.html#prod-Atom">Atom</a></emu-nt>, which in this case includes capture Strings numbered 2, 3, 4, and 5.</p>
|
||
</div></emu-note>
|
||
<emu-note><span class="note">Note 4</span><div class="note-contents">
|
||
<p>Step <emu-xref href="#step-repeatmatcher-done" id="_ref_691"><a href="text-processing.html#step-repeatmatcher-done">2.b</a></emu-xref> of the RepeatMatcher states that once the minimum number of repetitions has been satisfied, any more expansions of <emu-nt id="_ref_24345"><a href="text-processing.html#prod-Atom">Atom</a></emu-nt> that match the empty character sequence are not considered for further repetitions. This prevents the regular expression engine from falling into an infinite loop on patterns such as:</p>
|
||
<pre><code class="javascript hljs">/(a*)*/.<span class="hljs-title function_">exec</span>(<span class="hljs-string">"b"</span>)</code></pre>
|
||
<p>or the slightly more complicated:</p>
|
||
<pre><code class="javascript hljs">/(a*)b\<span class="hljs-number">1</span>+/.<span class="hljs-title function_">exec</span>(<span class="hljs-string">"baaaac"</span>)</code></pre>
|
||
<p>which returns the array</p>
|
||
<pre><code class="javascript hljs">[<span class="hljs-string">"b"</span>, <span class="hljs-string">""</span>]</code></pre>
|
||
</div></emu-note>
|
||
</emu-clause>
|
||
|
||
<emu-clause id="sec-emptymatcher" type="abstract operation" aoid="EmptyMatcher">
|
||
<h1><span class="secnum">22.2.2.3.2</span> EmptyMatcher ( )</h1>
|
||
<p>The abstract operation EmptyMatcher takes no arguments and returns a <emu-xref href="#pattern-matcher" id="_ref_11837"><a href="text-processing.html#pattern-matcher">Matcher</a></emu-xref>. It performs the following steps when called:</p>
|
||
<emu-alg><ol><li>Return a new <emu-xref href="#pattern-matcher" id="_ref_11838"><a href="text-processing.html#pattern-matcher">Matcher</a></emu-xref> with parameters (<var>x</var>, <var>c</var>) that captures nothing and performs the following steps when called:<ol><li><emu-xref href="#assert" id="_ref_11839"><a href="notational-conventions.html#assert">Assert</a></emu-xref>: <var>x</var> is a <emu-xref href="#pattern-matchstate" id="_ref_11840"><a href="text-processing.html#pattern-matchstate">MatchState</a></emu-xref>.</li><li><emu-xref href="#assert" id="_ref_11841"><a href="notational-conventions.html#assert">Assert</a></emu-xref>: <var>c</var> is a <emu-xref href="#pattern-matchercontinuation" id="_ref_11842"><a href="text-processing.html#pattern-matchercontinuation">MatcherContinuation</a></emu-xref>.</li><li>Return <var>c</var>(<var>x</var>).</li></ol></li></ol></emu-alg>
|
||
</emu-clause>
|
||
|
||
<emu-clause id="sec-matchtwoalternatives" type="abstract operation" aoid="MatchTwoAlternatives">
|
||
<h1><span class="secnum">22.2.2.3.3</span> MatchTwoAlternatives ( <var>m1</var>, <var>m2</var> )</h1>
|
||
<p>The abstract operation MatchTwoAlternatives takes arguments <var>m1</var> (a <emu-xref href="#pattern-matcher" id="_ref_11843"><a href="text-processing.html#pattern-matcher">Matcher</a></emu-xref>) and <var>m2</var> (a <emu-xref href="#pattern-matcher" id="_ref_11844"><a href="text-processing.html#pattern-matcher">Matcher</a></emu-xref>) and returns a <emu-xref href="#pattern-matcher" id="_ref_11845"><a href="text-processing.html#pattern-matcher">Matcher</a></emu-xref>. It performs the following steps when called:</p>
|
||
<emu-alg><ol><li>Return a new <emu-xref href="#pattern-matcher" id="_ref_11846"><a href="text-processing.html#pattern-matcher">Matcher</a></emu-xref> with parameters (<var>x</var>, <var>c</var>) that captures <var>m1</var> and <var>m2</var> and performs the following steps when called:<ol><li><emu-xref href="#assert" id="_ref_11847"><a href="notational-conventions.html#assert">Assert</a></emu-xref>: <var>x</var> is a <emu-xref href="#pattern-matchstate" id="_ref_11848"><a href="text-processing.html#pattern-matchstate">MatchState</a></emu-xref>.</li><li><emu-xref href="#assert" id="_ref_11849"><a href="notational-conventions.html#assert">Assert</a></emu-xref>: <var>c</var> is a <emu-xref href="#pattern-matchercontinuation" id="_ref_11850"><a href="text-processing.html#pattern-matchercontinuation">MatcherContinuation</a></emu-xref>.</li><li>Let <var>r</var> be <var>m1</var>(<var>x</var>, <var>c</var>).</li><li>If <var>r</var> is not <emu-const>failure</emu-const>, return <var>r</var>.</li><li>Return <var>m2</var>(<var>x</var>, <var>c</var>).</li></ol></li></ol></emu-alg>
|
||
</emu-clause>
|
||
|
||
<emu-clause id="sec-matchsequence" type="abstract operation" aoid="MatchSequence">
|
||
<h1><span class="secnum">22.2.2.3.4</span> MatchSequence ( <var>m1</var>, <var>m2</var>, <var>direction</var> )</h1>
|
||
<p>The abstract operation MatchSequence takes arguments <var>m1</var> (a <emu-xref href="#pattern-matcher" id="_ref_11851"><a href="text-processing.html#pattern-matcher">Matcher</a></emu-xref>), <var>m2</var> (a <emu-xref href="#pattern-matcher" id="_ref_11852"><a href="text-processing.html#pattern-matcher">Matcher</a></emu-xref>), and <var>direction</var> (<emu-const>forward</emu-const> or <emu-const>backward</emu-const>) and returns a <emu-xref href="#pattern-matcher" id="_ref_11853"><a href="text-processing.html#pattern-matcher">Matcher</a></emu-xref>. It performs the following steps when called:</p>
|
||
<emu-alg><ol><li>If <var>direction</var> is <emu-const>forward</emu-const>, then<ol><li>Return a new <emu-xref href="#pattern-matcher" id="_ref_11854"><a href="text-processing.html#pattern-matcher">Matcher</a></emu-xref> with parameters (<var>x</var>, <var>c</var>) that captures <var>m1</var> and <var>m2</var> and performs the following steps when called:<ol><li><emu-xref href="#assert" id="_ref_11855"><a href="notational-conventions.html#assert">Assert</a></emu-xref>: <var>x</var> is a <emu-xref href="#pattern-matchstate" id="_ref_11856"><a href="text-processing.html#pattern-matchstate">MatchState</a></emu-xref>.</li><li><emu-xref href="#assert" id="_ref_11857"><a href="notational-conventions.html#assert">Assert</a></emu-xref>: <var>c</var> is a <emu-xref href="#pattern-matchercontinuation" id="_ref_11858"><a href="text-processing.html#pattern-matchercontinuation">MatcherContinuation</a></emu-xref>.</li><li>Let <var>d</var> be a new <emu-xref href="#pattern-matchercontinuation" id="_ref_11859"><a href="text-processing.html#pattern-matchercontinuation">MatcherContinuation</a></emu-xref> with parameters (<var>y</var>) that captures <var>c</var> and <var>m2</var> and performs the following steps when called:<ol><li><emu-xref href="#assert" id="_ref_11860"><a href="notational-conventions.html#assert">Assert</a></emu-xref>: <var>y</var> is a <emu-xref href="#pattern-matchstate" id="_ref_11861"><a href="text-processing.html#pattern-matchstate">MatchState</a></emu-xref>.</li><li>Return <var>m2</var>(<var>y</var>, <var>c</var>).</li></ol></li><li>Return <var>m1</var>(<var>x</var>, <var>d</var>).</li></ol></li></ol></li><li><emu-xref href="#assert" id="_ref_11862"><a href="notational-conventions.html#assert">Assert</a></emu-xref>: <var>direction</var> is <emu-const>backward</emu-const>.</li><li>Return a new <emu-xref href="#pattern-matcher" id="_ref_11863"><a href="text-processing.html#pattern-matcher">Matcher</a></emu-xref> with parameters (<var>x</var>, <var>c</var>) that captures <var>m1</var> and <var>m2</var> and performs the following steps when called:<ol><li><emu-xref href="#assert" id="_ref_11864"><a href="notational-conventions.html#assert">Assert</a></emu-xref>: <var>x</var> is a <emu-xref href="#pattern-matchstate" id="_ref_11865"><a href="text-processing.html#pattern-matchstate">MatchState</a></emu-xref>.</li><li><emu-xref href="#assert" id="_ref_11866"><a href="notational-conventions.html#assert">Assert</a></emu-xref>: <var>c</var> is a <emu-xref href="#pattern-matchercontinuation" id="_ref_11867"><a href="text-processing.html#pattern-matchercontinuation">MatcherContinuation</a></emu-xref>.</li><li>Let <var>d</var> be a new <emu-xref href="#pattern-matchercontinuation" id="_ref_11868"><a href="text-processing.html#pattern-matchercontinuation">MatcherContinuation</a></emu-xref> with parameters (<var>y</var>) that captures <var>c</var> and <var>m1</var> and performs the following steps when called:<ol><li><emu-xref href="#assert" id="_ref_11869"><a href="notational-conventions.html#assert">Assert</a></emu-xref>: <var>y</var> is a <emu-xref href="#pattern-matchstate" id="_ref_11870"><a href="text-processing.html#pattern-matchstate">MatchState</a></emu-xref>.</li><li>Return <var>m1</var>(<var>y</var>, <var>c</var>).</li></ol></li><li>Return <var>m2</var>(<var>x</var>, <var>d</var>).</li></ol></li></ol></emu-alg>
|
||
</emu-clause>
|
||
</emu-clause>
|
||
|
||
<emu-clause id="sec-compileassertion" type="sdo" oldids="sec-assertion" aoid="CompileAssertion"><span id="sec-assertion"></span>
|
||
<h1><span class="secnum">22.2.2.4</span> Runtime Semantics: CompileAssertion</h1>
|
||
<p>The <emu-xref href="#sec-algorithm-conventions-syntax-directed-operations" id="_ref_11871"><a href="notational-conventions.html#sec-algorithm-conventions-syntax-directed-operations">syntax-directed operation</a></emu-xref> CompileAssertion takes argument <var>rer</var> (a <emu-xref href="#sec-regexp-records" id="_ref_11872"><a href="text-processing.html#sec-regexp-records">RegExp Record</a></emu-xref>) and returns a <emu-xref href="#pattern-matcher" id="_ref_11873"><a href="text-processing.html#pattern-matcher">Matcher</a></emu-xref>.</p>
|
||
<emu-note><span class="note">Note 1</span><div class="note-contents">
|
||
<p>This section is amended in <emu-xref href="#sec-compileassertion-annexb" id="_ref_692"><a href="additional-ecmascript-features-for-web-browsers.html#sec-compileassertion-annexb">B.1.2.6</a></emu-xref>.</p>
|
||
</div></emu-note>
|
||
<p>It is defined piecewise over the following productions:</p>
|
||
<emu-grammar><emu-production name="Assertion" type="lexical" collapsed="">
|
||
<emu-nt><a href="text-processing.html#prod-Assertion">Assertion</a></emu-nt> <emu-geq>::</emu-geq> <emu-rhs a="5yeieuod" id="prod-sVm_wok4"><emu-t>^</emu-t></emu-rhs>
|
||
</emu-production>
|
||
</emu-grammar>
|
||
<emu-alg><ol><li>Return a new <emu-xref href="#pattern-matcher" id="_ref_11874"><a href="text-processing.html#pattern-matcher">Matcher</a></emu-xref> with parameters (<var>x</var>, <var>c</var>) that captures <var>rer</var> and performs the following steps when called:<ol><li><emu-xref href="#assert" id="_ref_11875"><a href="notational-conventions.html#assert">Assert</a></emu-xref>: <var>x</var> is a <emu-xref href="#pattern-matchstate" id="_ref_11876"><a href="text-processing.html#pattern-matchstate">MatchState</a></emu-xref>.</li><li><emu-xref href="#assert" id="_ref_11877"><a href="notational-conventions.html#assert">Assert</a></emu-xref>: <var>c</var> is a <emu-xref href="#pattern-matchercontinuation" id="_ref_11878"><a href="text-processing.html#pattern-matchercontinuation">MatcherContinuation</a></emu-xref>.</li><li>Let <var>Input</var> be <var>x</var>.<var class="field">[[Input]]</var>.</li><li>Let <var>e</var> be <var>x</var>.<var class="field">[[EndIndex]]</var>.</li><li>If <var>e</var> = 0, or if <var>rer</var>.<var class="field">[[Multiline]]</var> is <emu-val>true</emu-val> and the character <var>Input</var>[<var>e</var> - 1] is matched by <emu-nt id="_ref_24346"><a href="ecmascript-language-lexical-grammar.html#prod-LineTerminator">LineTerminator</a></emu-nt>, then<ol><li>Return <var>c</var>(<var>x</var>).</li></ol></li><li>Return <emu-const>failure</emu-const>.</li></ol></li></ol></emu-alg>
|
||
<emu-note><span class="note">Note 2</span><div class="note-contents">
|
||
<p>Even when the <code>y</code> flag is used with a pattern, <code>^</code> always matches only at the beginning of <var>Input</var>, or (if <var>rer</var>.<var class="field">[[Multiline]]</var> is <emu-val>true</emu-val>) at the beginning of a line.</p>
|
||
</div></emu-note>
|
||
<emu-grammar><emu-production name="Assertion" type="lexical" collapsed="">
|
||
<emu-nt><a href="text-processing.html#prod-Assertion">Assertion</a></emu-nt> <emu-geq>::</emu-geq> <emu-rhs a="emlmkqfm" id="prod-STP3aqEM"><emu-t>$</emu-t></emu-rhs>
|
||
</emu-production>
|
||
</emu-grammar>
|
||
<emu-alg><ol><li>Return a new <emu-xref href="#pattern-matcher" id="_ref_11879"><a href="text-processing.html#pattern-matcher">Matcher</a></emu-xref> with parameters (<var>x</var>, <var>c</var>) that captures <var>rer</var> and performs the following steps when called:<ol><li><emu-xref href="#assert" id="_ref_11880"><a href="notational-conventions.html#assert">Assert</a></emu-xref>: <var>x</var> is a <emu-xref href="#pattern-matchstate" id="_ref_11881"><a href="text-processing.html#pattern-matchstate">MatchState</a></emu-xref>.</li><li><emu-xref href="#assert" id="_ref_11882"><a href="notational-conventions.html#assert">Assert</a></emu-xref>: <var>c</var> is a <emu-xref href="#pattern-matchercontinuation" id="_ref_11883"><a href="text-processing.html#pattern-matchercontinuation">MatcherContinuation</a></emu-xref>.</li><li>Let <var>Input</var> be <var>x</var>.<var class="field">[[Input]]</var>.</li><li>Let <var>e</var> be <var>x</var>.<var class="field">[[EndIndex]]</var>.</li><li>Let <var>InputLength</var> be the number of elements in <var>Input</var>.</li><li>If <var>e</var> = <var>InputLength</var>, or if <var>rer</var>.<var class="field">[[Multiline]]</var> is <emu-val>true</emu-val> and the character <var>Input</var>[<var>e</var>] is matched by <emu-nt id="_ref_24347"><a href="ecmascript-language-lexical-grammar.html#prod-LineTerminator">LineTerminator</a></emu-nt>, then<ol><li>Return <var>c</var>(<var>x</var>).</li></ol></li><li>Return <emu-const>failure</emu-const>.</li></ol></li></ol></emu-alg>
|
||
<emu-grammar><emu-production name="Assertion" type="lexical" collapsed="">
|
||
<emu-nt><a href="text-processing.html#prod-Assertion">Assertion</a></emu-nt> <emu-geq>::</emu-geq> <emu-rhs a="axxsqknu" id="prod-IZJSBUZJ"><emu-t>\b</emu-t></emu-rhs>
|
||
</emu-production>
|
||
</emu-grammar>
|
||
<emu-alg><ol><li>Return a new <emu-xref href="#pattern-matcher" id="_ref_11884"><a href="text-processing.html#pattern-matcher">Matcher</a></emu-xref> with parameters (<var>x</var>, <var>c</var>) that captures <var>rer</var> and performs the following steps when called:<ol><li><emu-xref href="#assert" id="_ref_11885"><a href="notational-conventions.html#assert">Assert</a></emu-xref>: <var>x</var> is a <emu-xref href="#pattern-matchstate" id="_ref_11886"><a href="text-processing.html#pattern-matchstate">MatchState</a></emu-xref>.</li><li><emu-xref href="#assert" id="_ref_11887"><a href="notational-conventions.html#assert">Assert</a></emu-xref>: <var>c</var> is a <emu-xref href="#pattern-matchercontinuation" id="_ref_11888"><a href="text-processing.html#pattern-matchercontinuation">MatcherContinuation</a></emu-xref>.</li><li>Let <var>Input</var> be <var>x</var>.<var class="field">[[Input]]</var>.</li><li>Let <var>e</var> be <var>x</var>.<var class="field">[[EndIndex]]</var>.</li><li>Let <var>a</var> be <emu-xref aoid="IsWordChar" id="_ref_11889"><a href="text-processing.html#sec-runtime-semantics-iswordchar-abstract-operation">IsWordChar</a></emu-xref>(<var>rer</var>, <var>Input</var>, <var>e</var> - 1).</li><li>Let <var>b</var> be <emu-xref aoid="IsWordChar" id="_ref_11890"><a href="text-processing.html#sec-runtime-semantics-iswordchar-abstract-operation">IsWordChar</a></emu-xref>(<var>rer</var>, <var>Input</var>, <var>e</var>).</li><li>If <var>a</var> is <emu-val>true</emu-val> and <var>b</var> is <emu-val>false</emu-val>, or if <var>a</var> is <emu-val>false</emu-val> and <var>b</var> is <emu-val>true</emu-val>, return <var>c</var>(<var>x</var>).</li><li>Return <emu-const>failure</emu-const>.</li></ol></li></ol></emu-alg>
|
||
<emu-grammar><emu-production name="Assertion" type="lexical" collapsed="">
|
||
<emu-nt><a href="text-processing.html#prod-Assertion">Assertion</a></emu-nt> <emu-geq>::</emu-geq> <emu-rhs a="lnx_opbv" id="prod-92fnNlhg"><emu-t>\B</emu-t></emu-rhs>
|
||
</emu-production>
|
||
</emu-grammar>
|
||
<emu-alg><ol><li>Return a new <emu-xref href="#pattern-matcher" id="_ref_11891"><a href="text-processing.html#pattern-matcher">Matcher</a></emu-xref> with parameters (<var>x</var>, <var>c</var>) that captures <var>rer</var> and performs the following steps when called:<ol><li><emu-xref href="#assert" id="_ref_11892"><a href="notational-conventions.html#assert">Assert</a></emu-xref>: <var>x</var> is a <emu-xref href="#pattern-matchstate" id="_ref_11893"><a href="text-processing.html#pattern-matchstate">MatchState</a></emu-xref>.</li><li><emu-xref href="#assert" id="_ref_11894"><a href="notational-conventions.html#assert">Assert</a></emu-xref>: <var>c</var> is a <emu-xref href="#pattern-matchercontinuation" id="_ref_11895"><a href="text-processing.html#pattern-matchercontinuation">MatcherContinuation</a></emu-xref>.</li><li>Let <var>Input</var> be <var>x</var>.<var class="field">[[Input]]</var>.</li><li>Let <var>e</var> be <var>x</var>.<var class="field">[[EndIndex]]</var>.</li><li>Let <var>a</var> be <emu-xref aoid="IsWordChar" id="_ref_11896"><a href="text-processing.html#sec-runtime-semantics-iswordchar-abstract-operation">IsWordChar</a></emu-xref>(<var>rer</var>, <var>Input</var>, <var>e</var> - 1).</li><li>Let <var>b</var> be <emu-xref aoid="IsWordChar" id="_ref_11897"><a href="text-processing.html#sec-runtime-semantics-iswordchar-abstract-operation">IsWordChar</a></emu-xref>(<var>rer</var>, <var>Input</var>, <var>e</var>).</li><li>If <var>a</var> is <emu-val>true</emu-val> and <var>b</var> is <emu-val>true</emu-val>, or if <var>a</var> is <emu-val>false</emu-val> and <var>b</var> is <emu-val>false</emu-val>, return <var>c</var>(<var>x</var>).</li><li>Return <emu-const>failure</emu-const>.</li></ol></li></ol></emu-alg>
|
||
<emu-grammar><emu-production name="Assertion" type="lexical" collapsed="">
|
||
<emu-nt><a href="text-processing.html#prod-Assertion">Assertion</a></emu-nt> <emu-geq>::</emu-geq> <emu-rhs a="fbtayxzo" id="prod-eBn333dp">
|
||
<emu-t>(?=</emu-t>
|
||
<emu-nt id="_ref_24348"><a href="text-processing.html#prod-Disjunction">Disjunction</a></emu-nt>
|
||
<emu-t>)</emu-t>
|
||
</emu-rhs>
|
||
</emu-production>
|
||
</emu-grammar>
|
||
<emu-alg><ol><li>Let <var>m</var> be <emu-xref aoid="CompileSubpattern" id="_ref_11898"><a href="text-processing.html#sec-compilesubpattern">CompileSubpattern</a></emu-xref> of <emu-nt id="_ref_24349"><a href="text-processing.html#prod-Disjunction">Disjunction</a></emu-nt> with arguments <var>rer</var> and <emu-const>forward</emu-const>.</li><li>Return a new <emu-xref href="#pattern-matcher" id="_ref_11899"><a href="text-processing.html#pattern-matcher">Matcher</a></emu-xref> with parameters (<var>x</var>, <var>c</var>) that captures <var>m</var> and performs the following steps when called:<ol><li><emu-xref href="#assert" id="_ref_11900"><a href="notational-conventions.html#assert">Assert</a></emu-xref>: <var>x</var> is a <emu-xref href="#pattern-matchstate" id="_ref_11901"><a href="text-processing.html#pattern-matchstate">MatchState</a></emu-xref>.</li><li><emu-xref href="#assert" id="_ref_11902"><a href="notational-conventions.html#assert">Assert</a></emu-xref>: <var>c</var> is a <emu-xref href="#pattern-matchercontinuation" id="_ref_11903"><a href="text-processing.html#pattern-matchercontinuation">MatcherContinuation</a></emu-xref>.</li><li>Let <var>d</var> be a new <emu-xref href="#pattern-matchercontinuation" id="_ref_11904"><a href="text-processing.html#pattern-matchercontinuation">MatcherContinuation</a></emu-xref> with parameters (<var>y</var>) that captures nothing and performs the following steps when called:<ol><li><emu-xref href="#assert" id="_ref_11905"><a href="notational-conventions.html#assert">Assert</a></emu-xref>: <var>y</var> is a <emu-xref href="#pattern-matchstate" id="_ref_11906"><a href="text-processing.html#pattern-matchstate">MatchState</a></emu-xref>.</li><li>Return <var>y</var>.</li></ol></li><li>Let <var>r</var> be <var>m</var>(<var>x</var>, <var>d</var>).</li><li>If <var>r</var> is <emu-const>failure</emu-const>, return <emu-const>failure</emu-const>.</li><li><emu-xref href="#assert" id="_ref_11907"><a href="notational-conventions.html#assert">Assert</a></emu-xref>: <var>r</var> is a <emu-xref href="#pattern-matchstate" id="_ref_11908"><a href="text-processing.html#pattern-matchstate">MatchState</a></emu-xref>.</li><li>Let <var>cap</var> be <var>r</var>.<var class="field">[[Captures]]</var>.</li><li>Let <var>Input</var> be <var>x</var>.<var class="field">[[Input]]</var>.</li><li>Let <var>xe</var> be <var>x</var>.<var class="field">[[EndIndex]]</var>.</li><li>Let <var>z</var> be the <emu-xref href="#pattern-matchstate" id="_ref_11909"><a href="text-processing.html#pattern-matchstate">MatchState</a></emu-xref> { <var class="field">[[Input]]</var>: <var>Input</var>, <var class="field">[[EndIndex]]</var>: <var>xe</var>, <var class="field">[[Captures]]</var>: <var>cap</var> }.</li><li>Return <var>c</var>(<var>z</var>).</li></ol></li></ol></emu-alg>
|
||
<emu-note><span class="note">Note 3</span><div class="note-contents">
|
||
<p>The form <code>(?=</code> <emu-nt id="_ref_24350"><a href="text-processing.html#prod-Disjunction">Disjunction</a></emu-nt> <code>)</code> specifies a zero-width positive lookahead. In order for it to succeed, the pattern inside <emu-nt id="_ref_24351"><a href="text-processing.html#prod-Disjunction">Disjunction</a></emu-nt> must match at the current position, but the current position is not advanced before matching the sequel. If <emu-nt id="_ref_24352"><a href="text-processing.html#prod-Disjunction">Disjunction</a></emu-nt> can match at the current position in several ways, only the first one is tried. Unlike other regular expression operators, there is no backtracking into a <code>(?=</code> form (this unusual behaviour is inherited from Perl). This only matters when the <emu-nt id="_ref_24353"><a href="text-processing.html#prod-Disjunction">Disjunction</a></emu-nt> contains capturing parentheses and the sequel of the pattern contains backreferences to those captures.</p>
|
||
<p>For example,</p>
|
||
<pre><code class="javascript hljs">/(?=(a+))/.<span class="hljs-title function_">exec</span>(<span class="hljs-string">"baaabac"</span>)</code></pre>
|
||
<p>matches the empty String immediately after the first <code>b</code> and therefore returns the array:</p>
|
||
<pre><code class="javascript hljs">[<span class="hljs-string">""</span>, <span class="hljs-string">"aaa"</span>]</code></pre>
|
||
<p>To illustrate the lack of backtracking into the lookahead, consider:</p>
|
||
<pre><code class="javascript hljs">/(?=(a+))a*b\<span class="hljs-number">1</span>/.<span class="hljs-title function_">exec</span>(<span class="hljs-string">"baaabac"</span>)</code></pre>
|
||
<p>This expression returns</p>
|
||
<pre><code class="javascript hljs">[<span class="hljs-string">"aba"</span>, <span class="hljs-string">"a"</span>]</code></pre>
|
||
<p>and not:</p>
|
||
<pre><code class="javascript hljs">[<span class="hljs-string">"aaaba"</span>, <span class="hljs-string">"a"</span>]</code></pre>
|
||
</div></emu-note>
|
||
<emu-grammar><emu-production name="Assertion" type="lexical" collapsed="">
|
||
<emu-nt><a href="text-processing.html#prod-Assertion">Assertion</a></emu-nt> <emu-geq>::</emu-geq> <emu-rhs a="uwxc-jvg" id="prod-R66yItqF">
|
||
<emu-t>(?!</emu-t>
|
||
<emu-nt id="_ref_24354"><a href="text-processing.html#prod-Disjunction">Disjunction</a></emu-nt>
|
||
<emu-t>)</emu-t>
|
||
</emu-rhs>
|
||
</emu-production>
|
||
</emu-grammar>
|
||
<emu-alg><ol><li>Let <var>m</var> be <emu-xref aoid="CompileSubpattern" id="_ref_11910"><a href="text-processing.html#sec-compilesubpattern">CompileSubpattern</a></emu-xref> of <emu-nt id="_ref_24355"><a href="text-processing.html#prod-Disjunction">Disjunction</a></emu-nt> with arguments <var>rer</var> and <emu-const>forward</emu-const>.</li><li>Return a new <emu-xref href="#pattern-matcher" id="_ref_11911"><a href="text-processing.html#pattern-matcher">Matcher</a></emu-xref> with parameters (<var>x</var>, <var>c</var>) that captures <var>m</var> and performs the following steps when called:<ol><li><emu-xref href="#assert" id="_ref_11912"><a href="notational-conventions.html#assert">Assert</a></emu-xref>: <var>x</var> is a <emu-xref href="#pattern-matchstate" id="_ref_11913"><a href="text-processing.html#pattern-matchstate">MatchState</a></emu-xref>.</li><li><emu-xref href="#assert" id="_ref_11914"><a href="notational-conventions.html#assert">Assert</a></emu-xref>: <var>c</var> is a <emu-xref href="#pattern-matchercontinuation" id="_ref_11915"><a href="text-processing.html#pattern-matchercontinuation">MatcherContinuation</a></emu-xref>.</li><li>Let <var>d</var> be a new <emu-xref href="#pattern-matchercontinuation" id="_ref_11916"><a href="text-processing.html#pattern-matchercontinuation">MatcherContinuation</a></emu-xref> with parameters (<var>y</var>) that captures nothing and performs the following steps when called:<ol><li><emu-xref href="#assert" id="_ref_11917"><a href="notational-conventions.html#assert">Assert</a></emu-xref>: <var>y</var> is a <emu-xref href="#pattern-matchstate" id="_ref_11918"><a href="text-processing.html#pattern-matchstate">MatchState</a></emu-xref>.</li><li>Return <var>y</var>.</li></ol></li><li>Let <var>r</var> be <var>m</var>(<var>x</var>, <var>d</var>).</li><li>If <var>r</var> is not <emu-const>failure</emu-const>, return <emu-const>failure</emu-const>.</li><li>Return <var>c</var>(<var>x</var>).</li></ol></li></ol></emu-alg>
|
||
<emu-note><span class="note">Note 4</span><div class="note-contents">
|
||
<p>The form <code>(?!</code> <emu-nt id="_ref_24356"><a href="text-processing.html#prod-Disjunction">Disjunction</a></emu-nt> <code>)</code> specifies a zero-width negative lookahead. In order for it to succeed, the pattern inside <emu-nt id="_ref_24357"><a href="text-processing.html#prod-Disjunction">Disjunction</a></emu-nt> must fail to match at the current position. The current position is not advanced before matching the sequel. <emu-nt id="_ref_24358"><a href="text-processing.html#prod-Disjunction">Disjunction</a></emu-nt> can contain capturing parentheses, but backreferences to them only make sense from within <emu-nt id="_ref_24359"><a href="text-processing.html#prod-Disjunction">Disjunction</a></emu-nt> itself. Backreferences to these capturing parentheses from elsewhere in the pattern always return <emu-val>undefined</emu-val> because the negative lookahead must fail for the pattern to succeed. For example,</p>
|
||
<pre><code class="javascript hljs">/(.*?)<span class="hljs-title function_">a</span>(?!(a+)b\2c)\<span class="hljs-number">2</span>(.*)/.<span class="hljs-title function_">exec</span>(<span class="hljs-string">"baaabaac"</span>)</code></pre>
|
||
<p>looks for an <code>a</code> not immediately followed by some positive number n of <code>a</code>'s, a <code>b</code>, another n <code>a</code>'s (specified by the first <code>\2</code>) and a <code>c</code>. The second <code>\2</code> is outside the negative lookahead, so it matches against <emu-val>undefined</emu-val> and therefore always succeeds. The whole expression returns the array:</p>
|
||
<pre><code class="javascript hljs">[<span class="hljs-string">"baaabaac"</span>, <span class="hljs-string">"ba"</span>, <span class="hljs-literal">undefined</span>, <span class="hljs-string">"abaac"</span>]</code></pre>
|
||
</div></emu-note>
|
||
<emu-grammar><emu-production name="Assertion" type="lexical" collapsed="">
|
||
<emu-nt><a href="text-processing.html#prod-Assertion">Assertion</a></emu-nt> <emu-geq>::</emu-geq> <emu-rhs a="usbmjkdr" id="prod-sZjx8A-T">
|
||
<emu-t>(?<=</emu-t>
|
||
<emu-nt id="_ref_24360"><a href="text-processing.html#prod-Disjunction">Disjunction</a></emu-nt>
|
||
<emu-t>)</emu-t>
|
||
</emu-rhs>
|
||
</emu-production>
|
||
</emu-grammar>
|
||
<emu-alg><ol><li>Let <var>m</var> be <emu-xref aoid="CompileSubpattern" id="_ref_11919"><a href="text-processing.html#sec-compilesubpattern">CompileSubpattern</a></emu-xref> of <emu-nt id="_ref_24361"><a href="text-processing.html#prod-Disjunction">Disjunction</a></emu-nt> with arguments <var>rer</var> and <emu-const>backward</emu-const>.</li><li>Return a new <emu-xref href="#pattern-matcher" id="_ref_11920"><a href="text-processing.html#pattern-matcher">Matcher</a></emu-xref> with parameters (<var>x</var>, <var>c</var>) that captures <var>m</var> and performs the following steps when called:<ol><li><emu-xref href="#assert" id="_ref_11921"><a href="notational-conventions.html#assert">Assert</a></emu-xref>: <var>x</var> is a <emu-xref href="#pattern-matchstate" id="_ref_11922"><a href="text-processing.html#pattern-matchstate">MatchState</a></emu-xref>.</li><li><emu-xref href="#assert" id="_ref_11923"><a href="notational-conventions.html#assert">Assert</a></emu-xref>: <var>c</var> is a <emu-xref href="#pattern-matchercontinuation" id="_ref_11924"><a href="text-processing.html#pattern-matchercontinuation">MatcherContinuation</a></emu-xref>.</li><li>Let <var>d</var> be a new <emu-xref href="#pattern-matchercontinuation" id="_ref_11925"><a href="text-processing.html#pattern-matchercontinuation">MatcherContinuation</a></emu-xref> with parameters (<var>y</var>) that captures nothing and performs the following steps when called:<ol><li><emu-xref href="#assert" id="_ref_11926"><a href="notational-conventions.html#assert">Assert</a></emu-xref>: <var>y</var> is a <emu-xref href="#pattern-matchstate" id="_ref_11927"><a href="text-processing.html#pattern-matchstate">MatchState</a></emu-xref>.</li><li>Return <var>y</var>.</li></ol></li><li>Let <var>r</var> be <var>m</var>(<var>x</var>, <var>d</var>).</li><li>If <var>r</var> is <emu-const>failure</emu-const>, return <emu-const>failure</emu-const>.</li><li><emu-xref href="#assert" id="_ref_11928"><a href="notational-conventions.html#assert">Assert</a></emu-xref>: <var>r</var> is a <emu-xref href="#pattern-matchstate" id="_ref_11929"><a href="text-processing.html#pattern-matchstate">MatchState</a></emu-xref>.</li><li>Let <var>cap</var> be <var>r</var>.<var class="field">[[Captures]]</var>.</li><li>Let <var>Input</var> be <var>x</var>.<var class="field">[[Input]]</var>.</li><li>Let <var>xe</var> be <var>x</var>.<var class="field">[[EndIndex]]</var>.</li><li>Let <var>z</var> be the <emu-xref href="#pattern-matchstate" id="_ref_11930"><a href="text-processing.html#pattern-matchstate">MatchState</a></emu-xref> { <var class="field">[[Input]]</var>: <var>Input</var>, <var class="field">[[EndIndex]]</var>: <var>xe</var>, <var class="field">[[Captures]]</var>: <var>cap</var> }.</li><li>Return <var>c</var>(<var>z</var>).</li></ol></li></ol></emu-alg>
|
||
<emu-grammar><emu-production name="Assertion" type="lexical" collapsed="">
|
||
<emu-nt><a href="text-processing.html#prod-Assertion">Assertion</a></emu-nt> <emu-geq>::</emu-geq> <emu-rhs a="6jj9rpbu" id="prod-OBuox7k0">
|
||
<emu-t>(?<!</emu-t>
|
||
<emu-nt id="_ref_24362"><a href="text-processing.html#prod-Disjunction">Disjunction</a></emu-nt>
|
||
<emu-t>)</emu-t>
|
||
</emu-rhs>
|
||
</emu-production>
|
||
</emu-grammar>
|
||
<emu-alg><ol><li>Let <var>m</var> be <emu-xref aoid="CompileSubpattern" id="_ref_11931"><a href="text-processing.html#sec-compilesubpattern">CompileSubpattern</a></emu-xref> of <emu-nt id="_ref_24363"><a href="text-processing.html#prod-Disjunction">Disjunction</a></emu-nt> with arguments <var>rer</var> and <emu-const>backward</emu-const>.</li><li>Return a new <emu-xref href="#pattern-matcher" id="_ref_11932"><a href="text-processing.html#pattern-matcher">Matcher</a></emu-xref> with parameters (<var>x</var>, <var>c</var>) that captures <var>m</var> and performs the following steps when called:<ol><li><emu-xref href="#assert" id="_ref_11933"><a href="notational-conventions.html#assert">Assert</a></emu-xref>: <var>x</var> is a <emu-xref href="#pattern-matchstate" id="_ref_11934"><a href="text-processing.html#pattern-matchstate">MatchState</a></emu-xref>.</li><li><emu-xref href="#assert" id="_ref_11935"><a href="notational-conventions.html#assert">Assert</a></emu-xref>: <var>c</var> is a <emu-xref href="#pattern-matchercontinuation" id="_ref_11936"><a href="text-processing.html#pattern-matchercontinuation">MatcherContinuation</a></emu-xref>.</li><li>Let <var>d</var> be a new <emu-xref href="#pattern-matchercontinuation" id="_ref_11937"><a href="text-processing.html#pattern-matchercontinuation">MatcherContinuation</a></emu-xref> with parameters (<var>y</var>) that captures nothing and performs the following steps when called:<ol><li><emu-xref href="#assert" id="_ref_11938"><a href="notational-conventions.html#assert">Assert</a></emu-xref>: <var>y</var> is a <emu-xref href="#pattern-matchstate" id="_ref_11939"><a href="text-processing.html#pattern-matchstate">MatchState</a></emu-xref>.</li><li>Return <var>y</var>.</li></ol></li><li>Let <var>r</var> be <var>m</var>(<var>x</var>, <var>d</var>).</li><li>If <var>r</var> is not <emu-const>failure</emu-const>, return <emu-const>failure</emu-const>.</li><li>Return <var>c</var>(<var>x</var>).</li></ol></li></ol></emu-alg>
|
||
|
||
<emu-clause id="sec-runtime-semantics-iswordchar-abstract-operation" type="abstract operation" aoid="IsWordChar">
|
||
<h1><span class="secnum">22.2.2.4.1</span> IsWordChar ( <var>rer</var>, <var>Input</var>, <var>e</var> )</h1>
|
||
<p>The abstract operation IsWordChar takes arguments <var>rer</var> (a <emu-xref href="#sec-regexp-records" id="_ref_11940"><a href="text-processing.html#sec-regexp-records">RegExp Record</a></emu-xref>), <var>Input</var> (a <emu-xref href="#sec-list-and-record-specification-type" id="_ref_11941"><a href="ecmascript-data-types-and-values.html#sec-list-and-record-specification-type">List</a></emu-xref> of characters), and <var>e</var> (an <emu-xref href="#integer" id="_ref_11942"><a href="notational-conventions.html#integer">integer</a></emu-xref>) and returns a Boolean. It performs the following steps when called:</p>
|
||
<emu-alg><ol><li>Let <var>InputLength</var> be the number of elements in <var>Input</var>.</li><li>If <var>e</var> = -1 or <var>e</var> = <var>InputLength</var>, return <emu-val>false</emu-val>.</li><li>Let <var>c</var> be the character <var>Input</var>[<var>e</var>].</li><li>If <emu-xref aoid="WordCharacters" id="_ref_11943"><a href="text-processing.html#sec-wordcharacters">WordCharacters</a></emu-xref>(<var>rer</var>) contains <var>c</var>, return <emu-val>true</emu-val>.</li><li>Return <emu-val>false</emu-val>.</li></ol></emu-alg>
|
||
</emu-clause>
|
||
</emu-clause>
|
||
|
||
<emu-clause id="sec-compilequantifier" type="sdo" oldids="sec-quantifier" aoid="CompileQuantifier"><span id="sec-quantifier"></span>
|
||
<h1><span class="secnum">22.2.2.5</span> Runtime Semantics: CompileQuantifier</h1>
|
||
<p>The <emu-xref href="#sec-algorithm-conventions-syntax-directed-operations" id="_ref_11944"><a href="notational-conventions.html#sec-algorithm-conventions-syntax-directed-operations">syntax-directed operation</a></emu-xref> CompileQuantifier takes no arguments and returns a <emu-xref href="#sec-list-and-record-specification-type" id="_ref_11945"><a href="ecmascript-data-types-and-values.html#sec-list-and-record-specification-type">Record</a></emu-xref> with fields <var class="field">[[Min]]</var> (a non-negative <emu-xref href="#integer" id="_ref_11946"><a href="notational-conventions.html#integer">integer</a></emu-xref>), <var class="field">[[Max]]</var> (a non-negative <emu-xref href="#integer" id="_ref_11947"><a href="notational-conventions.html#integer">integer</a></emu-xref> or +∞), and <var class="field">[[Greedy]]</var> (a Boolean). It is defined piecewise over the following productions:</p>
|
||
<emu-grammar><emu-production name="Quantifier" type="lexical" collapsed="">
|
||
<emu-nt><a href="text-processing.html#prod-Quantifier">Quantifier</a></emu-nt> <emu-geq>::</emu-geq> <emu-rhs a="dlini2nj" id="prod-9qV9mwu-"><emu-nt id="_ref_24364"><a href="text-processing.html#prod-QuantifierPrefix">QuantifierPrefix</a></emu-nt></emu-rhs>
|
||
</emu-production>
|
||
</emu-grammar>
|
||
<emu-alg><ol><li>Let <var>qp</var> be <emu-xref aoid="CompileQuantifierPrefix" id="_ref_11948"><a href="text-processing.html#sec-compilequantifierprefix">CompileQuantifierPrefix</a></emu-xref> of <emu-nt id="_ref_24365"><a href="text-processing.html#prod-QuantifierPrefix">QuantifierPrefix</a></emu-nt>.</li><li>Return the <emu-xref href="#sec-list-and-record-specification-type" id="_ref_11949"><a href="ecmascript-data-types-and-values.html#sec-list-and-record-specification-type">Record</a></emu-xref> { <var class="field">[[Min]]</var>: <var>qp</var>.<var class="field">[[Min]]</var>, <var class="field">[[Max]]</var>: <var>qp</var>.<var class="field">[[Max]]</var>, <var class="field">[[Greedy]]</var>: <emu-val>true</emu-val> }.</li></ol></emu-alg>
|
||
<emu-grammar><emu-production name="Quantifier" type="lexical" collapsed="">
|
||
<emu-nt><a href="text-processing.html#prod-Quantifier">Quantifier</a></emu-nt> <emu-geq>::</emu-geq> <emu-rhs a="cwtuervy" id="prod-qWoBDE8M">
|
||
<emu-nt id="_ref_24366"><a href="text-processing.html#prod-QuantifierPrefix">QuantifierPrefix</a></emu-nt>
|
||
<emu-t>?</emu-t>
|
||
</emu-rhs>
|
||
</emu-production>
|
||
</emu-grammar>
|
||
<emu-alg><ol><li>Let <var>qp</var> be <emu-xref aoid="CompileQuantifierPrefix" id="_ref_11950"><a href="text-processing.html#sec-compilequantifierprefix">CompileQuantifierPrefix</a></emu-xref> of <emu-nt id="_ref_24367"><a href="text-processing.html#prod-QuantifierPrefix">QuantifierPrefix</a></emu-nt>.</li><li>Return the <emu-xref href="#sec-list-and-record-specification-type" id="_ref_11951"><a href="ecmascript-data-types-and-values.html#sec-list-and-record-specification-type">Record</a></emu-xref> { <var class="field">[[Min]]</var>: <var>qp</var>.<var class="field">[[Min]]</var>, <var class="field">[[Max]]</var>: <var>qp</var>.<var class="field">[[Max]]</var>, <var class="field">[[Greedy]]</var>: <emu-val>false</emu-val> }.</li></ol></emu-alg>
|
||
</emu-clause>
|
||
|
||
<emu-clause id="sec-compilequantifierprefix" type="sdo" aoid="CompileQuantifierPrefix">
|
||
<h1><span class="secnum">22.2.2.6</span> Runtime Semantics: CompileQuantifierPrefix</h1>
|
||
<p>The <emu-xref href="#sec-algorithm-conventions-syntax-directed-operations" id="_ref_11952"><a href="notational-conventions.html#sec-algorithm-conventions-syntax-directed-operations">syntax-directed operation</a></emu-xref> CompileQuantifierPrefix takes no arguments and returns a <emu-xref href="#sec-list-and-record-specification-type" id="_ref_11953"><a href="ecmascript-data-types-and-values.html#sec-list-and-record-specification-type">Record</a></emu-xref> with fields <var class="field">[[Min]]</var> (a non-negative <emu-xref href="#integer" id="_ref_11954"><a href="notational-conventions.html#integer">integer</a></emu-xref>) and <var class="field">[[Max]]</var> (a non-negative <emu-xref href="#integer" id="_ref_11955"><a href="notational-conventions.html#integer">integer</a></emu-xref> or +∞). It is defined piecewise over the following productions:</p>
|
||
<emu-grammar><emu-production name="QuantifierPrefix" type="lexical" collapsed="">
|
||
<emu-nt><a href="text-processing.html#prod-QuantifierPrefix">QuantifierPrefix</a></emu-nt> <emu-geq>::</emu-geq> <emu-rhs a="sb5ztei-" id="prod-s8nl1xnS"><emu-t>*</emu-t></emu-rhs>
|
||
</emu-production>
|
||
</emu-grammar>
|
||
<emu-alg><ol><li>Return the <emu-xref href="#sec-list-and-record-specification-type" id="_ref_11956"><a href="ecmascript-data-types-and-values.html#sec-list-and-record-specification-type">Record</a></emu-xref> { <var class="field">[[Min]]</var>: 0, <var class="field">[[Max]]</var>: +∞ }.</li></ol></emu-alg>
|
||
<emu-grammar><emu-production name="QuantifierPrefix" type="lexical" collapsed="">
|
||
<emu-nt><a href="text-processing.html#prod-QuantifierPrefix">QuantifierPrefix</a></emu-nt> <emu-geq>::</emu-geq> <emu-rhs a="4dclbrwl" id="prod-4GxjzerI"><emu-t>+</emu-t></emu-rhs>
|
||
</emu-production>
|
||
</emu-grammar>
|
||
<emu-alg><ol><li>Return the <emu-xref href="#sec-list-and-record-specification-type" id="_ref_11957"><a href="ecmascript-data-types-and-values.html#sec-list-and-record-specification-type">Record</a></emu-xref> { <var class="field">[[Min]]</var>: 1, <var class="field">[[Max]]</var>: +∞ }.</li></ol></emu-alg>
|
||
<emu-grammar><emu-production name="QuantifierPrefix" type="lexical" collapsed="">
|
||
<emu-nt><a href="text-processing.html#prod-QuantifierPrefix">QuantifierPrefix</a></emu-nt> <emu-geq>::</emu-geq> <emu-rhs a="iy1xym7h" id="prod-xg-YUvEA"><emu-t>?</emu-t></emu-rhs>
|
||
</emu-production>
|
||
</emu-grammar>
|
||
<emu-alg><ol><li>Return the <emu-xref href="#sec-list-and-record-specification-type" id="_ref_11958"><a href="ecmascript-data-types-and-values.html#sec-list-and-record-specification-type">Record</a></emu-xref> { <var class="field">[[Min]]</var>: 0, <var class="field">[[Max]]</var>: 1 }.</li></ol></emu-alg>
|
||
<emu-grammar><emu-production name="QuantifierPrefix" type="lexical" collapsed="">
|
||
<emu-nt><a href="text-processing.html#prod-QuantifierPrefix">QuantifierPrefix</a></emu-nt> <emu-geq>::</emu-geq> <emu-rhs a="akk3tt2f" id="prod-cx_RnfxU">
|
||
<emu-t>{</emu-t>
|
||
<emu-nt id="_ref_24368"><a href="ecmascript-language-lexical-grammar.html#prod-DecimalDigits">DecimalDigits</a></emu-nt>
|
||
<emu-t>}</emu-t>
|
||
</emu-rhs>
|
||
</emu-production>
|
||
</emu-grammar>
|
||
<emu-alg><ol><li>Let <var>i</var> be the MV of <emu-nt id="_ref_24369"><a href="ecmascript-language-lexical-grammar.html#prod-DecimalDigits">DecimalDigits</a></emu-nt> (see <emu-xref href="#sec-literals-numeric-literals" id="_ref_693"><a href="ecmascript-language-lexical-grammar.html#sec-literals-numeric-literals">12.9.3</a></emu-xref>).</li><li>Return the <emu-xref href="#sec-list-and-record-specification-type" id="_ref_11959"><a href="ecmascript-data-types-and-values.html#sec-list-and-record-specification-type">Record</a></emu-xref> { <var class="field">[[Min]]</var>: <var>i</var>, <var class="field">[[Max]]</var>: <var>i</var> }.</li></ol></emu-alg>
|
||
<emu-grammar><emu-production name="QuantifierPrefix" type="lexical" collapsed="">
|
||
<emu-nt><a href="text-processing.html#prod-QuantifierPrefix">QuantifierPrefix</a></emu-nt> <emu-geq>::</emu-geq> <emu-rhs a="pmpxiyk5" id="prod-zaHyl8D0">
|
||
<emu-t>{</emu-t>
|
||
<emu-nt id="_ref_24370"><a href="ecmascript-language-lexical-grammar.html#prod-DecimalDigits">DecimalDigits</a></emu-nt>
|
||
<emu-t>,}</emu-t>
|
||
</emu-rhs>
|
||
</emu-production>
|
||
</emu-grammar>
|
||
<emu-alg><ol><li>Let <var>i</var> be the MV of <emu-nt id="_ref_24371"><a href="ecmascript-language-lexical-grammar.html#prod-DecimalDigits">DecimalDigits</a></emu-nt>.</li><li>Return the <emu-xref href="#sec-list-and-record-specification-type" id="_ref_11960"><a href="ecmascript-data-types-and-values.html#sec-list-and-record-specification-type">Record</a></emu-xref> { <var class="field">[[Min]]</var>: <var>i</var>, <var class="field">[[Max]]</var>: +∞ }.</li></ol></emu-alg>
|
||
<emu-grammar><emu-production name="QuantifierPrefix" type="lexical" collapsed="">
|
||
<emu-nt><a href="text-processing.html#prod-QuantifierPrefix">QuantifierPrefix</a></emu-nt> <emu-geq>::</emu-geq> <emu-rhs a="9hgpwdk0" id="prod-JGD-kmEs">
|
||
<emu-t>{</emu-t>
|
||
<emu-nt id="_ref_24372"><a href="ecmascript-language-lexical-grammar.html#prod-DecimalDigits">DecimalDigits</a></emu-nt>
|
||
<emu-t>,</emu-t>
|
||
<emu-nt id="_ref_24373"><a href="ecmascript-language-lexical-grammar.html#prod-DecimalDigits">DecimalDigits</a></emu-nt>
|
||
<emu-t>}</emu-t>
|
||
</emu-rhs>
|
||
</emu-production>
|
||
</emu-grammar>
|
||
<emu-alg><ol><li>Let <var>i</var> be the MV of the first <emu-nt id="_ref_24374"><a href="ecmascript-language-lexical-grammar.html#prod-DecimalDigits">DecimalDigits</a></emu-nt>.</li><li>Let <var>j</var> be the MV of the second <emu-nt id="_ref_24375"><a href="ecmascript-language-lexical-grammar.html#prod-DecimalDigits">DecimalDigits</a></emu-nt>.</li><li>Return the <emu-xref href="#sec-list-and-record-specification-type" id="_ref_11961"><a href="ecmascript-data-types-and-values.html#sec-list-and-record-specification-type">Record</a></emu-xref> { <var class="field">[[Min]]</var>: <var>i</var>, <var class="field">[[Max]]</var>: <var>j</var> }.</li></ol></emu-alg>
|
||
</emu-clause>
|
||
|
||
<emu-clause id="sec-compileatom" type="sdo" oldids="sec-atom,sec-atomescape,sec-characterescape,sec-decimalescape" aoid="CompileAtom"><span id="sec-decimalescape"></span><span id="sec-characterescape"></span><span id="sec-atomescape"></span><span id="sec-atom"></span>
|
||
<h1><span class="secnum">22.2.2.7</span> Runtime Semantics: CompileAtom</h1>
|
||
<p>The <emu-xref href="#sec-algorithm-conventions-syntax-directed-operations" id="_ref_11962"><a href="notational-conventions.html#sec-algorithm-conventions-syntax-directed-operations">syntax-directed operation</a></emu-xref> CompileAtom takes arguments <var>rer</var> (a <emu-xref href="#sec-regexp-records" id="_ref_11963"><a href="text-processing.html#sec-regexp-records">RegExp Record</a></emu-xref>) and <var>direction</var> (<emu-const>forward</emu-const> or <emu-const>backward</emu-const>) and returns a <emu-xref href="#pattern-matcher" id="_ref_11964"><a href="text-processing.html#pattern-matcher">Matcher</a></emu-xref>.</p>
|
||
<emu-note><span class="note">Note 1</span><div class="note-contents">
|
||
<p>This section is amended in <emu-xref href="#sec-compileatom-annexb" id="_ref_694"><a href="additional-ecmascript-features-for-web-browsers.html#sec-compileatom-annexb">B.1.2.7</a></emu-xref>.</p>
|
||
</div></emu-note>
|
||
|
||
<!-- Atom -->
|
||
<p>It is defined piecewise over the following productions:</p>
|
||
<emu-grammar><emu-production name="Atom" type="lexical" collapsed="">
|
||
<emu-nt><a href="text-processing.html#prod-Atom">Atom</a></emu-nt> <emu-geq>::</emu-geq> <emu-rhs a="vv9sxhyc" id="prod-Js9cL8Bl"><emu-nt id="_ref_24376"><a href="text-processing.html#prod-PatternCharacter">PatternCharacter</a></emu-nt></emu-rhs>
|
||
</emu-production>
|
||
</emu-grammar>
|
||
<emu-alg><ol><li>Let <var>ch</var> be the character matched by <emu-nt id="_ref_24377"><a href="text-processing.html#prod-PatternCharacter">PatternCharacter</a></emu-nt>.</li><li>Let <var>A</var> be a one-element <emu-xref href="#pattern-charset" id="_ref_11965"><a href="text-processing.html#pattern-charset">CharSet</a></emu-xref> containing the character <var>ch</var>.</li><li>Return <emu-xref aoid="CharacterSetMatcher" id="_ref_11966"><a href="text-processing.html#sec-runtime-semantics-charactersetmatcher-abstract-operation">CharacterSetMatcher</a></emu-xref>(<var>rer</var>, <var>A</var>, <emu-val>false</emu-val>, <var>direction</var>).</li></ol></emu-alg>
|
||
<emu-grammar><emu-production name="Atom" type="lexical" collapsed="">
|
||
<emu-nt><a href="text-processing.html#prod-Atom">Atom</a></emu-nt> <emu-geq>::</emu-geq> <emu-rhs a="lljkc4zd" id="prod-HeZ4ZCvZ"><emu-t>.</emu-t></emu-rhs>
|
||
</emu-production>
|
||
</emu-grammar>
|
||
<emu-alg><ol><li>Let <var>A</var> be <emu-xref aoid="AllCharacters" id="_ref_11967"><a href="text-processing.html#sec-allcharacters">AllCharacters</a></emu-xref>(<var>rer</var>).</li><li>If <var>rer</var>.<var class="field">[[DotAll]]</var> is not <emu-val>true</emu-val>, then<ol><li>Remove from <var>A</var> all characters corresponding to a code point on the right-hand side of the <emu-nt id="_ref_24378"><a href="ecmascript-language-lexical-grammar.html#prod-LineTerminator">LineTerminator</a></emu-nt> production.</li></ol></li><li>Return <emu-xref aoid="CharacterSetMatcher" id="_ref_11968"><a href="text-processing.html#sec-runtime-semantics-charactersetmatcher-abstract-operation">CharacterSetMatcher</a></emu-xref>(<var>rer</var>, <var>A</var>, <emu-val>false</emu-val>, <var>direction</var>).</li></ol></emu-alg>
|
||
<emu-grammar><emu-production name="Atom" type="lexical" collapsed="">
|
||
<emu-nt><a href="text-processing.html#prod-Atom">Atom</a></emu-nt> <emu-geq>::</emu-geq> <emu-rhs a="zqqoud41" id="prod-lKfl4ziO"><emu-nt id="_ref_24379"><a href="text-processing.html#prod-CharacterClass">CharacterClass</a></emu-nt></emu-rhs>
|
||
</emu-production>
|
||
</emu-grammar>
|
||
<emu-alg><ol><li>Let <var>cc</var> be <emu-xref aoid="CompileCharacterClass" id="_ref_11969"><a href="text-processing.html#sec-compilecharacterclass">CompileCharacterClass</a></emu-xref> of <emu-nt id="_ref_24380"><a href="text-processing.html#prod-CharacterClass">CharacterClass</a></emu-nt> with argument <var>rer</var>.</li><li>Let <var>cs</var> be <var>cc</var>.<var class="field">[[CharSet]]</var>.</li><li>If <var>rer</var>.<var class="field">[[UnicodeSets]]</var> is <emu-val>false</emu-val>, or if every <emu-xref href="#sec-pattern-notation" id="_ref_11970"><a href="text-processing.html#sec-pattern-notation">CharSetElement</a></emu-xref> of <var>cs</var> consists of a single character (including if <var>cs</var> is empty), return <emu-xref aoid="CharacterSetMatcher" id="_ref_11971"><a href="text-processing.html#sec-runtime-semantics-charactersetmatcher-abstract-operation">CharacterSetMatcher</a></emu-xref>(<var>rer</var>, <var>cs</var>, <var>cc</var>.<var class="field">[[Invert]]</var>, <var>direction</var>).</li><li><emu-xref href="#assert" id="_ref_11972"><a href="notational-conventions.html#assert">Assert</a></emu-xref>: <var>cc</var>.<var class="field">[[Invert]]</var> is <emu-val>false</emu-val>.</li><li>Let <var>lm</var> be an empty <emu-xref href="#sec-list-and-record-specification-type" id="_ref_11973"><a href="ecmascript-data-types-and-values.html#sec-list-and-record-specification-type">List</a></emu-xref> of <emu-xref href="#pattern-matcher" id="_ref_11974"><a href="text-processing.html#pattern-matcher">Matchers</a></emu-xref>.</li><li>For each <emu-xref href="#sec-pattern-notation" id="_ref_11975"><a href="text-processing.html#sec-pattern-notation">CharSetElement</a></emu-xref> <var>s</var> in <var>cs</var> containing more than 1 character, iterating in descending order of length, do<ol><li>Let <var>cs2</var> be a one-element <emu-xref href="#pattern-charset" id="_ref_11976"><a href="text-processing.html#pattern-charset">CharSet</a></emu-xref> containing the last code point of <var>s</var>.</li><li>Let <var>m2</var> be <emu-xref aoid="CharacterSetMatcher" id="_ref_11977"><a href="text-processing.html#sec-runtime-semantics-charactersetmatcher-abstract-operation">CharacterSetMatcher</a></emu-xref>(<var>rer</var>, <var>cs2</var>, <emu-val>false</emu-val>, <var>direction</var>).</li><li>For each code point <var>c1</var> in <var>s</var>, iterating backwards from its second-to-last code point, do<ol><li>Let <var>cs1</var> be a one-element <emu-xref href="#pattern-charset" id="_ref_11978"><a href="text-processing.html#pattern-charset">CharSet</a></emu-xref> containing <var>c1</var>.</li><li>Let <var>m1</var> be <emu-xref aoid="CharacterSetMatcher" id="_ref_11979"><a href="text-processing.html#sec-runtime-semantics-charactersetmatcher-abstract-operation">CharacterSetMatcher</a></emu-xref>(<var>rer</var>, <var>cs1</var>, <emu-val>false</emu-val>, <var>direction</var>).</li><li>Set <var>m2</var> to <emu-xref aoid="MatchSequence" id="_ref_11980"><a href="text-processing.html#sec-matchsequence">MatchSequence</a></emu-xref>(<var>m1</var>, <var>m2</var>, <var>direction</var>).</li></ol></li><li>Append <var>m2</var> to <var>lm</var>.</li></ol></li><li>Let <var>singles</var> be the <emu-xref href="#pattern-charset" id="_ref_11981"><a href="text-processing.html#pattern-charset">CharSet</a></emu-xref> containing every <emu-xref href="#sec-pattern-notation" id="_ref_11982"><a href="text-processing.html#sec-pattern-notation">CharSetElement</a></emu-xref> of <var>cs</var> that consists of a single character.</li><li>Append <emu-xref aoid="CharacterSetMatcher" id="_ref_11983"><a href="text-processing.html#sec-runtime-semantics-charactersetmatcher-abstract-operation">CharacterSetMatcher</a></emu-xref>(<var>rer</var>, <var>singles</var>, <emu-val>false</emu-val>, <var>direction</var>) to <var>lm</var>.</li><li>If <var>cs</var> contains the empty sequence of characters, append <emu-xref aoid="EmptyMatcher" id="_ref_11984"><a href="text-processing.html#sec-emptymatcher">EmptyMatcher</a></emu-xref>() to <var>lm</var>.</li><li>Let <var>m2</var> be the last <emu-xref href="#pattern-matcher" id="_ref_11985"><a href="text-processing.html#pattern-matcher">Matcher</a></emu-xref> in <var>lm</var>.</li><li>For each <emu-xref href="#pattern-matcher" id="_ref_11986"><a href="text-processing.html#pattern-matcher">Matcher</a></emu-xref> <var>m1</var> of <var>lm</var>, iterating backwards from its second-to-last element, do<ol><li>Set <var>m2</var> to <emu-xref aoid="MatchTwoAlternatives" id="_ref_11987"><a href="text-processing.html#sec-matchtwoalternatives">MatchTwoAlternatives</a></emu-xref>(<var>m1</var>, <var>m2</var>).</li></ol></li><li>Return <var>m2</var>.</li></ol></emu-alg>
|
||
<emu-grammar><emu-production name="Atom" type="lexical" collapsed="">
|
||
<emu-nt><a href="text-processing.html#prod-Atom">Atom</a></emu-nt> <emu-geq>::</emu-geq> <emu-rhs a="lnltxn63" id="prod-rOrnsPez">
|
||
<emu-t>(</emu-t>
|
||
<emu-nt optional="" id="_ref_24381"><a href="text-processing.html#prod-GroupSpecifier">GroupSpecifier</a><emu-mods><emu-opt>opt</emu-opt></emu-mods></emu-nt>
|
||
<emu-nt id="_ref_24382"><a href="text-processing.html#prod-Disjunction">Disjunction</a></emu-nt>
|
||
<emu-t>)</emu-t>
|
||
</emu-rhs>
|
||
</emu-production>
|
||
</emu-grammar>
|
||
<emu-alg><ol><li>Let <var>m</var> be <emu-xref aoid="CompileSubpattern" id="_ref_11988"><a href="text-processing.html#sec-compilesubpattern">CompileSubpattern</a></emu-xref> of <emu-nt id="_ref_24383"><a href="text-processing.html#prod-Disjunction">Disjunction</a></emu-nt> with arguments <var>rer</var> and <var>direction</var>.</li><li>Let <var>parenIndex</var> be <emu-xref aoid="CountLeftCapturingParensBefore" id="_ref_11989"><a href="text-processing.html#sec-countleftcapturingparensbefore">CountLeftCapturingParensBefore</a></emu-xref>(<emu-nt id="_ref_24384"><a href="text-processing.html#prod-Atom">Atom</a></emu-nt>).</li><li>Return a new <emu-xref href="#pattern-matcher" id="_ref_11990"><a href="text-processing.html#pattern-matcher">Matcher</a></emu-xref> with parameters (<var>x</var>, <var>c</var>) that captures <var>direction</var>, <var>m</var>, and <var>parenIndex</var> and performs the following steps when called:<ol><li><emu-xref href="#assert" id="_ref_11991"><a href="notational-conventions.html#assert">Assert</a></emu-xref>: <var>x</var> is a <emu-xref href="#pattern-matchstate" id="_ref_11992"><a href="text-processing.html#pattern-matchstate">MatchState</a></emu-xref>.</li><li><emu-xref href="#assert" id="_ref_11993"><a href="notational-conventions.html#assert">Assert</a></emu-xref>: <var>c</var> is a <emu-xref href="#pattern-matchercontinuation" id="_ref_11994"><a href="text-processing.html#pattern-matchercontinuation">MatcherContinuation</a></emu-xref>.</li><li>Let <var>d</var> be a new <emu-xref href="#pattern-matchercontinuation" id="_ref_11995"><a href="text-processing.html#pattern-matchercontinuation">MatcherContinuation</a></emu-xref> with parameters (<var>y</var>) that captures <var>x</var>, <var>c</var>, <var>direction</var>, and <var>parenIndex</var> and performs the following steps when called:<ol><li><emu-xref href="#assert" id="_ref_11996"><a href="notational-conventions.html#assert">Assert</a></emu-xref>: <var>y</var> is a <emu-xref href="#pattern-matchstate" id="_ref_11997"><a href="text-processing.html#pattern-matchstate">MatchState</a></emu-xref>.</li><li>Let <var>cap</var> be a copy of <var>y</var>.<var class="field">[[Captures]]</var>.</li><li>Let <var>Input</var> be <var>x</var>.<var class="field">[[Input]]</var>.</li><li>Let <var>xe</var> be <var>x</var>.<var class="field">[[EndIndex]]</var>.</li><li>Let <var>ye</var> be <var>y</var>.<var class="field">[[EndIndex]]</var>.</li><li>If <var>direction</var> is <emu-const>forward</emu-const>, then<ol><li><emu-xref href="#assert" id="_ref_11998"><a href="notational-conventions.html#assert">Assert</a></emu-xref>: <var>xe</var> ≤ <var>ye</var>.</li><li>Let <var>r</var> be the <emu-xref href="#pattern-capturerange" id="_ref_11999"><a href="text-processing.html#pattern-capturerange">CaptureRange</a></emu-xref> { <var class="field">[[StartIndex]]</var>: <var>xe</var>, <var class="field">[[EndIndex]]</var>: <var>ye</var> }.</li></ol></li><li>Else,<ol><li><emu-xref href="#assert" id="_ref_12000"><a href="notational-conventions.html#assert">Assert</a></emu-xref>: <var>direction</var> is <emu-const>backward</emu-const>.</li><li><emu-xref href="#assert" id="_ref_12001"><a href="notational-conventions.html#assert">Assert</a></emu-xref>: <var>ye</var> ≤ <var>xe</var>.</li><li>Let <var>r</var> be the <emu-xref href="#pattern-capturerange" id="_ref_12002"><a href="text-processing.html#pattern-capturerange">CaptureRange</a></emu-xref> { <var class="field">[[StartIndex]]</var>: <var>ye</var>, <var class="field">[[EndIndex]]</var>: <var>xe</var> }.</li></ol></li><li>Set <var>cap</var>[<var>parenIndex</var> + 1] to <var>r</var>.</li><li>Let <var>z</var> be the <emu-xref href="#pattern-matchstate" id="_ref_12003"><a href="text-processing.html#pattern-matchstate">MatchState</a></emu-xref> { <var class="field">[[Input]]</var>: <var>Input</var>, <var class="field">[[EndIndex]]</var>: <var>ye</var>, <var class="field">[[Captures]]</var>: <var>cap</var> }.</li><li>Return <var>c</var>(<var>z</var>).</li></ol></li><li>Return <var>m</var>(<var>x</var>, <var>d</var>).</li></ol></li></ol></emu-alg>
|
||
<emu-note><span class="note">Note 2</span><div class="note-contents">
|
||
<p>Parentheses of the form <code>(</code> <emu-nt id="_ref_24385"><a href="text-processing.html#prod-Disjunction">Disjunction</a></emu-nt> <code>)</code> serve both to group the components of the <emu-nt id="_ref_24386"><a href="text-processing.html#prod-Disjunction">Disjunction</a></emu-nt> pattern together and to save the result of the match. The result can be used either in a backreference (<code>\</code> followed by a non-zero decimal number), referenced in a replace String, or returned as part of an array from the regular expression matching <emu-xref href="#sec-abstract-closure" id="_ref_12004"><a href="ecmascript-data-types-and-values.html#sec-abstract-closure">Abstract Closure</a></emu-xref>. To inhibit the capturing behaviour of parentheses, use the form <code>(?:</code> <emu-nt id="_ref_24387"><a href="text-processing.html#prod-Disjunction">Disjunction</a></emu-nt> <code>)</code> instead.</p>
|
||
</div></emu-note>
|
||
<emu-grammar><emu-production name="Atom" type="lexical" collapsed="">
|
||
<emu-nt><a href="text-processing.html#prod-Atom">Atom</a></emu-nt> <emu-geq>::</emu-geq> <emu-rhs a="a-bf9noz" id="prod-jyyHsTvC">
|
||
<emu-t>(?</emu-t>
|
||
<emu-nt id="_ref_24388"><a href="text-processing.html#prod-RegularExpressionModifiers">RegularExpressionModifiers</a></emu-nt>
|
||
<emu-t>:</emu-t>
|
||
<emu-nt id="_ref_24389"><a href="text-processing.html#prod-Disjunction">Disjunction</a></emu-nt>
|
||
<emu-t>)</emu-t>
|
||
</emu-rhs>
|
||
</emu-production>
|
||
</emu-grammar>
|
||
<emu-alg><ol><li>Let <var>addModifiers</var> be the <emu-xref href="#sec-algorithm-conventions-syntax-directed-operations" id="_ref_12005"><a href="notational-conventions.html#sec-algorithm-conventions-syntax-directed-operations">source text matched by</a></emu-xref> <emu-nt id="_ref_24390"><a href="text-processing.html#prod-RegularExpressionModifiers">RegularExpressionModifiers</a></emu-nt>.</li><li>Let <var>removeModifiers</var> be the empty String.</li><li>Let <var>modifiedRer</var> be <emu-xref aoid="UpdateModifiers" id="_ref_12006"><a href="text-processing.html#sec-updatemodifiers">UpdateModifiers</a></emu-xref>(<var>rer</var>, <emu-xref aoid="CodePointsToString" id="_ref_12007"><a href="ecmascript-language-source-code.html#sec-codepointstostring">CodePointsToString</a></emu-xref>(<var>addModifiers</var>), <var>removeModifiers</var>).</li><li>Return <emu-xref aoid="CompileSubpattern" id="_ref_12008"><a href="text-processing.html#sec-compilesubpattern">CompileSubpattern</a></emu-xref> of <emu-nt id="_ref_24391"><a href="text-processing.html#prod-Disjunction">Disjunction</a></emu-nt> with arguments <var>modifiedRer</var> and <var>direction</var>.</li></ol></emu-alg>
|
||
<emu-grammar><emu-production name="Atom" type="lexical" collapsed="">
|
||
<emu-nt><a href="text-processing.html#prod-Atom">Atom</a></emu-nt> <emu-geq>::</emu-geq> <emu-rhs a="qocvabie" id="prod-sL7vmg03">
|
||
<emu-t>(?</emu-t>
|
||
<emu-nt id="_ref_24392"><a href="text-processing.html#prod-RegularExpressionModifiers">RegularExpressionModifiers</a></emu-nt>
|
||
<emu-t>-</emu-t>
|
||
<emu-nt id="_ref_24393"><a href="text-processing.html#prod-RegularExpressionModifiers">RegularExpressionModifiers</a></emu-nt>
|
||
<emu-t>:</emu-t>
|
||
<emu-nt id="_ref_24394"><a href="text-processing.html#prod-Disjunction">Disjunction</a></emu-nt>
|
||
<emu-t>)</emu-t>
|
||
</emu-rhs>
|
||
</emu-production>
|
||
</emu-grammar>
|
||
<emu-alg><ol><li>Let <var>addModifiers</var> be the <emu-xref href="#sec-algorithm-conventions-syntax-directed-operations" id="_ref_12009"><a href="notational-conventions.html#sec-algorithm-conventions-syntax-directed-operations">source text matched by</a></emu-xref> the first <emu-nt id="_ref_24395"><a href="text-processing.html#prod-RegularExpressionModifiers">RegularExpressionModifiers</a></emu-nt>.</li><li>Let <var>removeModifiers</var> be the <emu-xref href="#sec-algorithm-conventions-syntax-directed-operations" id="_ref_12010"><a href="notational-conventions.html#sec-algorithm-conventions-syntax-directed-operations">source text matched by</a></emu-xref> the second <emu-nt id="_ref_24396"><a href="text-processing.html#prod-RegularExpressionModifiers">RegularExpressionModifiers</a></emu-nt>.</li><li>Let <var>modifiedRer</var> be <emu-xref aoid="UpdateModifiers" id="_ref_12011"><a href="text-processing.html#sec-updatemodifiers">UpdateModifiers</a></emu-xref>(<var>rer</var>, <emu-xref aoid="CodePointsToString" id="_ref_12012"><a href="ecmascript-language-source-code.html#sec-codepointstostring">CodePointsToString</a></emu-xref>(<var>addModifiers</var>), <emu-xref aoid="CodePointsToString" id="_ref_12013"><a href="ecmascript-language-source-code.html#sec-codepointstostring">CodePointsToString</a></emu-xref>(<var>removeModifiers</var>)).</li><li>Return <emu-xref aoid="CompileSubpattern" id="_ref_12014"><a href="text-processing.html#sec-compilesubpattern">CompileSubpattern</a></emu-xref> of <emu-nt id="_ref_24397"><a href="text-processing.html#prod-Disjunction">Disjunction</a></emu-nt> with arguments <var>modifiedRer</var> and <var>direction</var>.</li></ol></emu-alg>
|
||
|
||
<!-- AtomEscape -->
|
||
<emu-grammar><emu-production name="AtomEscape" type="lexical" collapsed="">
|
||
<emu-nt><a href="text-processing.html#prod-AtomEscape">AtomEscape</a></emu-nt> <emu-geq>::</emu-geq> <emu-rhs a="fr_5bnut" id="prod-cCYT06VF"><emu-nt id="_ref_24398"><a href="text-processing.html#prod-DecimalEscape">DecimalEscape</a></emu-nt></emu-rhs>
|
||
</emu-production>
|
||
</emu-grammar>
|
||
<emu-alg><ol><li>Let <var>n</var> be the <emu-xref aoid="CapturingGroupNumber" id="_ref_12015"><a href="text-processing.html#sec-patterns-static-semantics-capturing-group-number">CapturingGroupNumber</a></emu-xref> of <emu-nt id="_ref_24399"><a href="text-processing.html#prod-DecimalEscape">DecimalEscape</a></emu-nt>.</li><li><emu-xref href="#assert" id="_ref_12016"><a href="notational-conventions.html#assert">Assert</a></emu-xref>: <var>n</var> ≤ <var>rer</var>.<var class="field">[[CapturingGroupsCount]]</var>.</li><li>Return <emu-xref aoid="BackreferenceMatcher" id="_ref_12017"><a href="text-processing.html#sec-backreference-matcher">BackreferenceMatcher</a></emu-xref>(<var>rer</var>, « <var>n</var> », <var>direction</var>).</li></ol></emu-alg>
|
||
<emu-note><span class="note">Note 3</span><div class="note-contents">
|
||
<p>An escape sequence of the form <code>\</code> followed by a non-zero decimal number <var>n</var> matches the result of the <var>n</var><sup>th</sup> set of capturing parentheses (<emu-xref href="#sec-pattern-notation" id="_ref_695"><a href="text-processing.html#sec-pattern-notation">22.2.2.1</a></emu-xref>). It is an error if the regular expression has fewer than <var>n</var> capturing parentheses. If the regular expression has <var>n</var> or more capturing parentheses but the <var>n</var><sup>th</sup> one is <emu-val>undefined</emu-val> because it has not captured anything, then the backreference always succeeds.</p>
|
||
</div></emu-note>
|
||
<emu-grammar><emu-production name="AtomEscape" type="lexical" collapsed="">
|
||
<emu-nt><a href="text-processing.html#prod-AtomEscape">AtomEscape</a></emu-nt> <emu-geq>::</emu-geq> <emu-rhs a="fjarvpc8" id="prod-HH-Xi2Q_"><emu-nt id="_ref_24400"><a href="text-processing.html#prod-CharacterEscape">CharacterEscape</a></emu-nt></emu-rhs>
|
||
</emu-production>
|
||
</emu-grammar>
|
||
<emu-alg><ol><li>Let <var>cv</var> be the <emu-xref aoid="CharacterValue" id="_ref_12018"><a href="text-processing.html#sec-patterns-static-semantics-character-value">CharacterValue</a></emu-xref> of <emu-nt id="_ref_24401"><a href="text-processing.html#prod-CharacterEscape">CharacterEscape</a></emu-nt>.</li><li>Let <var>ch</var> be the character whose character value is <var>cv</var>.</li><li>Let <var>A</var> be a one-element <emu-xref href="#pattern-charset" id="_ref_12019"><a href="text-processing.html#pattern-charset">CharSet</a></emu-xref> containing the character <var>ch</var>.</li><li>Return <emu-xref aoid="CharacterSetMatcher" id="_ref_12020"><a href="text-processing.html#sec-runtime-semantics-charactersetmatcher-abstract-operation">CharacterSetMatcher</a></emu-xref>(<var>rer</var>, <var>A</var>, <emu-val>false</emu-val>, <var>direction</var>).</li></ol></emu-alg>
|
||
<emu-grammar><emu-production name="AtomEscape" type="lexical" collapsed="">
|
||
<emu-nt><a href="text-processing.html#prod-AtomEscape">AtomEscape</a></emu-nt> <emu-geq>::</emu-geq> <emu-rhs a="bww-5j2p" id="prod-k2ESRh0v"><emu-nt id="_ref_24402"><a href="text-processing.html#prod-CharacterClassEscape">CharacterClassEscape</a></emu-nt></emu-rhs>
|
||
</emu-production>
|
||
</emu-grammar>
|
||
<emu-alg><ol><li>Let <var>cs</var> be <emu-xref aoid="CompileToCharSet" id="_ref_12021"><a href="text-processing.html#sec-compiletocharset">CompileToCharSet</a></emu-xref> of <emu-nt id="_ref_24403"><a href="text-processing.html#prod-CharacterClassEscape">CharacterClassEscape</a></emu-nt> with argument <var>rer</var>.</li><li>If <var>rer</var>.<var class="field">[[UnicodeSets]]</var> is <emu-val>false</emu-val>, or if every <emu-xref href="#sec-pattern-notation" id="_ref_12022"><a href="text-processing.html#sec-pattern-notation">CharSetElement</a></emu-xref> of <var>cs</var> consists of a single character (including if <var>cs</var> is empty), return <emu-xref aoid="CharacterSetMatcher" id="_ref_12023"><a href="text-processing.html#sec-runtime-semantics-charactersetmatcher-abstract-operation">CharacterSetMatcher</a></emu-xref>(<var>rer</var>, <var>cs</var>, <emu-val>false</emu-val>, <var>direction</var>).</li><li>Let <var>lm</var> be an empty <emu-xref href="#sec-list-and-record-specification-type" id="_ref_12024"><a href="ecmascript-data-types-and-values.html#sec-list-and-record-specification-type">List</a></emu-xref> of <emu-xref href="#pattern-matcher" id="_ref_12025"><a href="text-processing.html#pattern-matcher">Matchers</a></emu-xref>.</li><li>For each <emu-xref href="#sec-pattern-notation" id="_ref_12026"><a href="text-processing.html#sec-pattern-notation">CharSetElement</a></emu-xref> <var>s</var> in <var>cs</var> containing more than 1 character, iterating in descending order of length, do<ol><li>Let <var>cs2</var> be a one-element <emu-xref href="#pattern-charset" id="_ref_12027"><a href="text-processing.html#pattern-charset">CharSet</a></emu-xref> containing the last code point of <var>s</var>.</li><li>Let <var>m2</var> be <emu-xref aoid="CharacterSetMatcher" id="_ref_12028"><a href="text-processing.html#sec-runtime-semantics-charactersetmatcher-abstract-operation">CharacterSetMatcher</a></emu-xref>(<var>rer</var>, <var>cs2</var>, <emu-val>false</emu-val>, <var>direction</var>).</li><li>For each code point <var>c1</var> in <var>s</var>, iterating backwards from its second-to-last code point, do<ol><li>Let <var>cs1</var> be a one-element <emu-xref href="#pattern-charset" id="_ref_12029"><a href="text-processing.html#pattern-charset">CharSet</a></emu-xref> containing <var>c1</var>.</li><li>Let <var>m1</var> be <emu-xref aoid="CharacterSetMatcher" id="_ref_12030"><a href="text-processing.html#sec-runtime-semantics-charactersetmatcher-abstract-operation">CharacterSetMatcher</a></emu-xref>(<var>rer</var>, <var>cs1</var>, <emu-val>false</emu-val>, <var>direction</var>).</li><li>Set <var>m2</var> to <emu-xref aoid="MatchSequence" id="_ref_12031"><a href="text-processing.html#sec-matchsequence">MatchSequence</a></emu-xref>(<var>m1</var>, <var>m2</var>, <var>direction</var>).</li></ol></li><li>Append <var>m2</var> to <var>lm</var>.</li></ol></li><li>Let <var>singles</var> be the <emu-xref href="#pattern-charset" id="_ref_12032"><a href="text-processing.html#pattern-charset">CharSet</a></emu-xref> containing every <emu-xref href="#sec-pattern-notation" id="_ref_12033"><a href="text-processing.html#sec-pattern-notation">CharSetElement</a></emu-xref> of <var>cs</var> that consists of a single character.</li><li>Append <emu-xref aoid="CharacterSetMatcher" id="_ref_12034"><a href="text-processing.html#sec-runtime-semantics-charactersetmatcher-abstract-operation">CharacterSetMatcher</a></emu-xref>(<var>rer</var>, <var>singles</var>, <emu-val>false</emu-val>, <var>direction</var>) to <var>lm</var>.</li><li>If <var>cs</var> contains the empty sequence of characters, append <emu-xref aoid="EmptyMatcher" id="_ref_12035"><a href="text-processing.html#sec-emptymatcher">EmptyMatcher</a></emu-xref>() to <var>lm</var>.</li><li>Let <var>m2</var> be the last <emu-xref href="#pattern-matcher" id="_ref_12036"><a href="text-processing.html#pattern-matcher">Matcher</a></emu-xref> in <var>lm</var>.</li><li>For each <emu-xref href="#pattern-matcher" id="_ref_12037"><a href="text-processing.html#pattern-matcher">Matcher</a></emu-xref> <var>m1</var> of <var>lm</var>, iterating backwards from its second-to-last element, do<ol><li>Set <var>m2</var> to <emu-xref aoid="MatchTwoAlternatives" id="_ref_12038"><a href="text-processing.html#sec-matchtwoalternatives">MatchTwoAlternatives</a></emu-xref>(<var>m1</var>, <var>m2</var>).</li></ol></li><li>Return <var>m2</var>.</li></ol></emu-alg>
|
||
<emu-grammar><emu-production name="AtomEscape" type="lexical" collapsed="">
|
||
<emu-nt><a href="text-processing.html#prod-AtomEscape">AtomEscape</a></emu-nt> <emu-geq>::</emu-geq> <emu-rhs a="dd_xjonr" id="prod-VB-OogXI">
|
||
<emu-t>k</emu-t>
|
||
<emu-nt id="_ref_24404"><a href="text-processing.html#prod-GroupName">GroupName</a></emu-nt>
|
||
</emu-rhs>
|
||
</emu-production>
|
||
</emu-grammar>
|
||
<emu-alg><ol><li>Let <var>matchingGroupSpecifiers</var> be <emu-xref aoid="GroupSpecifiersThatMatch" id="_ref_12039"><a href="text-processing.html#sec-groupspecifiersthatmatch">GroupSpecifiersThatMatch</a></emu-xref>(<emu-nt id="_ref_24405"><a href="text-processing.html#prod-GroupName">GroupName</a></emu-nt>).</li><li>Let <var>parenIndices</var> be a new empty <emu-xref href="#sec-list-and-record-specification-type" id="_ref_12040"><a href="ecmascript-data-types-and-values.html#sec-list-and-record-specification-type">List</a></emu-xref>.</li><li>For each <emu-nt id="_ref_24406"><a href="text-processing.html#prod-GroupSpecifier">GroupSpecifier</a></emu-nt> <var>groupSpecifier</var> of <var>matchingGroupSpecifiers</var>, do<ol><li>Let <var>parenIndex</var> be <emu-xref aoid="CountLeftCapturingParensBefore" id="_ref_12041"><a href="text-processing.html#sec-countleftcapturingparensbefore">CountLeftCapturingParensBefore</a></emu-xref>(<var>groupSpecifier</var>).</li><li>Append <var>parenIndex</var> to <var>parenIndices</var>.</li></ol></li><li>Return <emu-xref aoid="BackreferenceMatcher" id="_ref_12042"><a href="text-processing.html#sec-backreference-matcher">BackreferenceMatcher</a></emu-xref>(<var>rer</var>, <var>parenIndices</var>, <var>direction</var>).</li></ol></emu-alg>
|
||
|
||
<emu-clause id="sec-runtime-semantics-charactersetmatcher-abstract-operation" type="abstract operation" aoid="CharacterSetMatcher">
|
||
<h1><span class="secnum">22.2.2.7.1</span> CharacterSetMatcher ( <var>rer</var>, <var>A</var>, <var>invert</var>, <var>direction</var> )</h1>
|
||
<p>The abstract operation CharacterSetMatcher takes arguments <var>rer</var> (a <emu-xref href="#sec-regexp-records" id="_ref_12043"><a href="text-processing.html#sec-regexp-records">RegExp Record</a></emu-xref>), <var>A</var> (a <emu-xref href="#pattern-charset" id="_ref_12044"><a href="text-processing.html#pattern-charset">CharSet</a></emu-xref>), <var>invert</var> (a Boolean), and <var>direction</var> (<emu-const>forward</emu-const> or <emu-const>backward</emu-const>) and returns a <emu-xref href="#pattern-matcher" id="_ref_12045"><a href="text-processing.html#pattern-matcher">Matcher</a></emu-xref>. It performs the following steps when called:</p>
|
||
<emu-alg><ol><li>If <var>rer</var>.<var class="field">[[UnicodeSets]]</var> is <emu-val>true</emu-val>, then<ol><li><emu-xref href="#assert" id="_ref_12046"><a href="notational-conventions.html#assert">Assert</a></emu-xref>: <var>invert</var> is <emu-val>false</emu-val>.</li><li><emu-xref href="#assert" id="_ref_12047"><a href="notational-conventions.html#assert">Assert</a></emu-xref>: Every <emu-xref href="#sec-pattern-notation" id="_ref_12048"><a href="text-processing.html#sec-pattern-notation">CharSetElement</a></emu-xref> of <var>A</var> consists of a single character.</li></ol></li><li>Return a new <emu-xref href="#pattern-matcher" id="_ref_12049"><a href="text-processing.html#pattern-matcher">Matcher</a></emu-xref> with parameters (<var>x</var>, <var>c</var>) that captures <var>rer</var>, <var>A</var>, <var>invert</var>, and <var>direction</var> and performs the following steps when called:<ol><li><emu-xref href="#assert" id="_ref_12050"><a href="notational-conventions.html#assert">Assert</a></emu-xref>: <var>x</var> is a <emu-xref href="#pattern-matchstate" id="_ref_12051"><a href="text-processing.html#pattern-matchstate">MatchState</a></emu-xref>.</li><li><emu-xref href="#assert" id="_ref_12052"><a href="notational-conventions.html#assert">Assert</a></emu-xref>: <var>c</var> is a <emu-xref href="#pattern-matchercontinuation" id="_ref_12053"><a href="text-processing.html#pattern-matchercontinuation">MatcherContinuation</a></emu-xref>.</li><li>Let <var>Input</var> be <var>x</var>.<var class="field">[[Input]]</var>.</li><li>Let <var>e</var> be <var>x</var>.<var class="field">[[EndIndex]]</var>.</li><li>If <var>direction</var> is <emu-const>forward</emu-const>, let <var>f</var> be <var>e</var> + 1.</li><li>Else, let <var>f</var> be <var>e</var> - 1.</li><li>Let <var>InputLength</var> be the number of elements in <var>Input</var>.</li><li>If <var>f</var> < 0 or <var>f</var> > <var>InputLength</var>, return <emu-const>failure</emu-const>.</li><li>Let <var>index</var> be <emu-xref aoid="min" id="_ref_12054"><a href="notational-conventions.html#eqn-min">min</a></emu-xref>(<var>e</var>, <var>f</var>).</li><li>Let <var>ch</var> be the character <var>Input</var>[<var>index</var>].</li><li>Let <var>cc</var> be <emu-xref aoid="Canonicalize" id="_ref_12055"><a href="text-processing.html#sec-runtime-semantics-canonicalize-ch">Canonicalize</a></emu-xref>(<var>rer</var>, <var>ch</var>).</li><li>If there exists a <emu-xref href="#sec-pattern-notation" id="_ref_12056"><a href="text-processing.html#sec-pattern-notation">CharSetElement</a></emu-xref> in <var>A</var> containing exactly one character <var>a</var> such that <emu-xref aoid="Canonicalize" id="_ref_12057"><a href="text-processing.html#sec-runtime-semantics-canonicalize-ch">Canonicalize</a></emu-xref>(<var>rer</var>, <var>a</var>) is <var>cc</var>, let <var>found</var> be <emu-val>true</emu-val>; else let <var>found</var> be <emu-val>false</emu-val>.</li><li>If <var>invert</var> is <emu-val>false</emu-val> and <var>found</var> is <emu-val>false</emu-val>, return <emu-const>failure</emu-const>.</li><li>If <var>invert</var> is <emu-val>true</emu-val> and <var>found</var> is <emu-val>true</emu-val>, return <emu-const>failure</emu-const>.</li><li>Let <var>cap</var> be <var>x</var>.<var class="field">[[Captures]]</var>.</li><li>Let <var>y</var> be the <emu-xref href="#pattern-matchstate" id="_ref_12058"><a href="text-processing.html#pattern-matchstate">MatchState</a></emu-xref> { <var class="field">[[Input]]</var>: <var>Input</var>, <var class="field">[[EndIndex]]</var>: <var>f</var>, <var class="field">[[Captures]]</var>: <var>cap</var> }.</li><li>Return <var>c</var>(<var>y</var>).</li></ol></li></ol></emu-alg>
|
||
</emu-clause>
|
||
|
||
<emu-clause id="sec-backreference-matcher" type="abstract operation" aoid="BackreferenceMatcher">
|
||
<h1><span class="secnum">22.2.2.7.2</span> BackreferenceMatcher ( <var>rer</var>, <var>ns</var>, <var>direction</var> )</h1>
|
||
<p>The abstract operation BackreferenceMatcher takes arguments <var>rer</var> (a <emu-xref href="#sec-regexp-records" id="_ref_12059"><a href="text-processing.html#sec-regexp-records">RegExp Record</a></emu-xref>), <var>ns</var> (a <emu-xref href="#sec-list-and-record-specification-type" id="_ref_12060"><a href="ecmascript-data-types-and-values.html#sec-list-and-record-specification-type">List</a></emu-xref> of positive <emu-xref href="#integer" id="_ref_12061"><a href="notational-conventions.html#integer">integers</a></emu-xref>), and <var>direction</var> (<emu-const>forward</emu-const> or <emu-const>backward</emu-const>) and returns a <emu-xref href="#pattern-matcher" id="_ref_12062"><a href="text-processing.html#pattern-matcher">Matcher</a></emu-xref>. It performs the following steps when called:</p>
|
||
<emu-alg><ol><li>Return a new <emu-xref href="#pattern-matcher" id="_ref_12063"><a href="text-processing.html#pattern-matcher">Matcher</a></emu-xref> with parameters (<var>x</var>, <var>c</var>) that captures <var>rer</var>, <var>ns</var>, and <var>direction</var> and performs the following steps when called:<ol><li><emu-xref href="#assert" id="_ref_12064"><a href="notational-conventions.html#assert">Assert</a></emu-xref>: <var>x</var> is a <emu-xref href="#pattern-matchstate" id="_ref_12065"><a href="text-processing.html#pattern-matchstate">MatchState</a></emu-xref>.</li><li><emu-xref href="#assert" id="_ref_12066"><a href="notational-conventions.html#assert">Assert</a></emu-xref>: <var>c</var> is a <emu-xref href="#pattern-matchercontinuation" id="_ref_12067"><a href="text-processing.html#pattern-matchercontinuation">MatcherContinuation</a></emu-xref>.</li><li>Let <var>Input</var> be <var>x</var>.<var class="field">[[Input]]</var>.</li><li>Let <var>cap</var> be <var>x</var>.<var class="field">[[Captures]]</var>.</li><li>Let <var>r</var> be <emu-val>undefined</emu-val>.</li><li>For each <emu-xref href="#integer" id="_ref_12068"><a href="notational-conventions.html#integer">integer</a></emu-xref> <var>n</var> of <var>ns</var>, do<ol><li>If <var>cap</var>[<var>n</var>] is not <emu-val>undefined</emu-val>, then<ol><li><emu-xref href="#assert" id="_ref_12069"><a href="notational-conventions.html#assert">Assert</a></emu-xref>: <var>r</var> is <emu-val>undefined</emu-val>.</li><li>Set <var>r</var> to <var>cap</var>[<var>n</var>].</li></ol></li></ol></li><li>If <var>r</var> is <emu-val>undefined</emu-val>, return <var>c</var>(<var>x</var>).</li><li>Let <var>e</var> be <var>x</var>.<var class="field">[[EndIndex]]</var>.</li><li>Let <var>rs</var> be <var>r</var>.<var class="field">[[StartIndex]]</var>.</li><li>Let <var>re</var> be <var>r</var>.<var class="field">[[EndIndex]]</var>.</li><li>Let <var>len</var> be <var>re</var> - <var>rs</var>.</li><li>If <var>direction</var> is <emu-const>forward</emu-const>, let <var>f</var> be <var>e</var> + <var>len</var>.</li><li>Else, let <var>f</var> be <var>e</var> - <var>len</var>.</li><li>Let <var>InputLength</var> be the number of elements in <var>Input</var>.</li><li>If <var>f</var> < 0 or <var>f</var> > <var>InputLength</var>, return <emu-const>failure</emu-const>.</li><li>Let <var>g</var> be <emu-xref aoid="min" id="_ref_12070"><a href="notational-conventions.html#eqn-min">min</a></emu-xref>(<var>e</var>, <var>f</var>).</li><li>If there exists an <emu-xref href="#integer" id="_ref_12071"><a href="notational-conventions.html#integer">integer</a></emu-xref> <var>i</var> in the <emu-xref href="#interval" id="_ref_12072"><a href="notational-conventions.html#interval">interval</a></emu-xref> from 0 (inclusive) to <var>len</var> (exclusive) such that <emu-xref aoid="Canonicalize" id="_ref_12073"><a href="text-processing.html#sec-runtime-semantics-canonicalize-ch">Canonicalize</a></emu-xref>(<var>rer</var>, <var>Input</var>[<var>rs</var> + <var>i</var>]) is not <emu-xref aoid="Canonicalize" id="_ref_12074"><a href="text-processing.html#sec-runtime-semantics-canonicalize-ch">Canonicalize</a></emu-xref>(<var>rer</var>, <var>Input</var>[<var>g</var> + <var>i</var>]), return <emu-const>failure</emu-const>.</li><li>Let <var>y</var> be the <emu-xref href="#pattern-matchstate" id="_ref_12075"><a href="text-processing.html#pattern-matchstate">MatchState</a></emu-xref> { <var class="field">[[Input]]</var>: <var>Input</var>, <var class="field">[[EndIndex]]</var>: <var>f</var>, <var class="field">[[Captures]]</var>: <var>cap</var> }.</li><li>Return <var>c</var>(<var>y</var>).</li></ol></li></ol></emu-alg>
|
||
</emu-clause>
|
||
|
||
<emu-clause id="sec-runtime-semantics-canonicalize-ch" type="abstract operation" aoid="Canonicalize">
|
||
<h1><span class="secnum">22.2.2.7.3</span> Canonicalize ( <var>rer</var>, <var>ch</var> )</h1>
|
||
<p>The abstract operation Canonicalize takes arguments <var>rer</var> (a <emu-xref href="#sec-regexp-records" id="_ref_12076"><a href="text-processing.html#sec-regexp-records">RegExp Record</a></emu-xref>) and <var>ch</var> (a character) and returns a character. It performs the following steps when called:</p>
|
||
<emu-alg><ol><li>If <emu-xref aoid="HasEitherUnicodeFlag" id="_ref_12077"><a href="text-processing.html#sec-runtime-semantics-haseitherunicodeflag-abstract-operation">HasEitherUnicodeFlag</a></emu-xref>(<var>rer</var>) is <emu-val>true</emu-val> and <var>rer</var>.<var class="field">[[IgnoreCase]]</var> is <emu-val>true</emu-val>, then<ol><li>If the file <a href="https://unicode.org/Public/UCD/latest/ucd/CaseFolding.txt"><code>CaseFolding.txt</code></a> of the Unicode Character Database provides a simple or common case folding mapping for <var>ch</var>, return the result of applying that mapping to <var>ch</var>.</li><li>Return <var>ch</var>.</li></ol></li><li>If <var>rer</var>.<var class="field">[[IgnoreCase]]</var> is <emu-val>false</emu-val>, return <var>ch</var>.</li><li><emu-xref href="#assert" id="_ref_12078"><a href="notational-conventions.html#assert">Assert</a></emu-xref>: <var>ch</var> is a UTF-16 code unit.</li><li>Let <var>cp</var> be the code point whose numeric value is the numeric value of <var>ch</var>.</li><li>Let <var>u</var> be toUppercase(« <var>cp</var> »), according to the Unicode Default Case Conversion algorithm.</li><li>Let <var>uStr</var> be <emu-xref aoid="CodePointsToString" id="_ref_12079"><a href="ecmascript-language-source-code.html#sec-codepointstostring">CodePointsToString</a></emu-xref>(<var>u</var>).</li><li>If the length of <var>uStr</var> ≠ 1, return <var>ch</var>.</li><li>Let <var>cu</var> be <var>uStr</var>'s single code unit element.</li><li>If the numeric value of <var>ch</var> ≥ 128 and the numeric value of <var>cu</var> < 128, return <var>ch</var>.</li><li>Return <var>cu</var>.</li></ol></emu-alg>
|
||
<emu-note><span class="note">Note</span><div class="note-contents">
|
||
<p>In case-insignificant matches when <emu-xref aoid="HasEitherUnicodeFlag" id="_ref_12080"><a href="text-processing.html#sec-runtime-semantics-haseitherunicodeflag-abstract-operation">HasEitherUnicodeFlag</a></emu-xref>(<var>rer</var>) is <emu-val>true</emu-val>, all characters are implicitly case-folded using the simple mapping provided by the Unicode Standard immediately before they are compared. The simple mapping always maps to a single code point, so it does not map, for example, <code>ß</code> (U+00DF LATIN SMALL LETTER SHARP S) to <code>ss</code> or <code>SS</code>. It may however map code points outside the Basic Latin block to code points within it—for example, <code>ſ</code> (U+017F LATIN SMALL LETTER LONG S) case-folds to <code>s</code> (U+0073 LATIN SMALL LETTER S) and <code>K</code> (U+212A KELVIN SIGN) case-folds to <code>k</code> (U+006B LATIN SMALL LETTER K). Strings containing those code points are matched by regular expressions such as <code>/[a-z]/ui</code>.</p>
|
||
<p>In case-insignificant matches when <emu-xref aoid="HasEitherUnicodeFlag" id="_ref_12081"><a href="text-processing.html#sec-runtime-semantics-haseitherunicodeflag-abstract-operation">HasEitherUnicodeFlag</a></emu-xref>(<var>rer</var>) is <emu-val>false</emu-val>, the mapping is based on Unicode Default Case Conversion algorithm toUppercase rather than toCasefold, which results in some subtle differences. For example, <code>Ω</code> (U+2126 OHM SIGN) is mapped by toUppercase to itself but by toCasefold to <code>ω</code> (U+03C9 GREEK SMALL LETTER OMEGA) along with <code>Ω</code> (U+03A9 GREEK CAPITAL LETTER OMEGA), so <emu-val>"\u2126"</emu-val> is matched by <code>/[ω]/ui</code> and <code>/[\u03A9]/ui</code> but not by <code>/[ω]/i</code> or <code>/[\u03A9]/i</code>. Also, no code point outside the Basic Latin block is mapped to a code point within it, so strings such as <emu-val>"\u017F ſ"</emu-val> and <emu-val>"\u212A K"</emu-val> are not matched by <code>/[a-z]/i</code>.</p>
|
||
</div></emu-note>
|
||
</emu-clause>
|
||
|
||
<emu-clause id="sec-updatemodifiers" type="abstract operation" aoid="UpdateModifiers">
|
||
<h1><span class="secnum">22.2.2.7.4</span> UpdateModifiers ( <var>rer</var>, <var>add</var>, <var>remove</var> )</h1>
|
||
<p>The abstract operation UpdateModifiers takes arguments <var>rer</var> (a <emu-xref href="#sec-regexp-records" id="_ref_12082"><a href="text-processing.html#sec-regexp-records">RegExp Record</a></emu-xref>), <var>add</var> (a String), and <var>remove</var> (a String) and returns a <emu-xref href="#sec-regexp-records" id="_ref_12083"><a href="text-processing.html#sec-regexp-records">RegExp Record</a></emu-xref>. It performs the following steps when called:</p>
|
||
<emu-alg><ol><li><emu-xref href="#assert" id="_ref_12084"><a href="notational-conventions.html#assert">Assert</a></emu-xref>: <var>add</var> and <var>remove</var> have no elements in common.</li><li>Let <var>ignoreCase</var> be <var>rer</var>.<var class="field">[[IgnoreCase]]</var>.</li><li>Let <var>multiline</var> be <var>rer</var>.<var class="field">[[Multiline]]</var>.</li><li>Let <var>dotAll</var> be <var>rer</var>.<var class="field">[[DotAll]]</var>.</li><li>Let <var>unicode</var> be <var>rer</var>.<var class="field">[[Unicode]]</var>.</li><li>Let <var>unicodeSets</var> be <var>rer</var>.<var class="field">[[UnicodeSets]]</var>.</li><li>Let <var>capturingGroupsCount</var> be <var>rer</var>.<var class="field">[[CapturingGroupsCount]]</var>.</li><li>If <var>remove</var> contains <emu-val>"i"</emu-val>, set <var>ignoreCase</var> to <emu-val>false</emu-val>.</li><li>Else if <var>add</var> contains <emu-val>"i"</emu-val>, set <var>ignoreCase</var> to <emu-val>true</emu-val>.</li><li>If <var>remove</var> contains <emu-val>"m"</emu-val>, set <var>multiline</var> to <emu-val>false</emu-val>.</li><li>Else if <var>add</var> contains <emu-val>"m"</emu-val>, set <var>multiline</var> to <emu-val>true</emu-val>.</li><li>If <var>remove</var> contains <emu-val>"s"</emu-val>, set <var>dotAll</var> to <emu-val>false</emu-val>.</li><li>Else if <var>add</var> contains <emu-val>"s"</emu-val>, set <var>dotAll</var> to <emu-val>true</emu-val>.</li><li>Return the <emu-xref href="#sec-regexp-records" id="_ref_12085"><a href="text-processing.html#sec-regexp-records">RegExp Record</a></emu-xref> { <var class="field">[[IgnoreCase]]</var>: <var>ignoreCase</var>, <var class="field">[[Multiline]]</var>: <var>multiline</var>, <var class="field">[[DotAll]]</var>: <var>dotAll</var>, <var class="field">[[Unicode]]</var>: <var>unicode</var>, <var class="field">[[UnicodeSets]]</var>: <var>unicodeSets</var>, <var class="field">[[CapturingGroupsCount]]</var>: <var>capturingGroupsCount</var> }.</li></ol></emu-alg>
|
||
</emu-clause>
|
||
</emu-clause>
|
||
|
||
<emu-clause id="sec-compilecharacterclass" type="sdo" oldids="sec-characterclass" aoid="CompileCharacterClass"><span id="sec-characterclass"></span>
|
||
<h1><span class="secnum">22.2.2.8</span> Runtime Semantics: CompileCharacterClass</h1>
|
||
<p>The <emu-xref href="#sec-algorithm-conventions-syntax-directed-operations" id="_ref_12086"><a href="notational-conventions.html#sec-algorithm-conventions-syntax-directed-operations">syntax-directed operation</a></emu-xref> CompileCharacterClass takes argument <var>rer</var> (a <emu-xref href="#sec-regexp-records" id="_ref_12087"><a href="text-processing.html#sec-regexp-records">RegExp Record</a></emu-xref>) and returns a <emu-xref href="#sec-list-and-record-specification-type" id="_ref_12088"><a href="ecmascript-data-types-and-values.html#sec-list-and-record-specification-type">Record</a></emu-xref> with fields <var class="field">[[CharSet]]</var> (a <emu-xref href="#pattern-charset" id="_ref_12089"><a href="text-processing.html#pattern-charset">CharSet</a></emu-xref>) and <var class="field">[[Invert]]</var> (a Boolean). It is defined piecewise over the following productions:</p>
|
||
<emu-grammar><emu-production name="CharacterClass" type="lexical" collapsed="">
|
||
<emu-nt><a href="text-processing.html#prod-CharacterClass">CharacterClass</a></emu-nt> <emu-geq>::</emu-geq> <emu-rhs a="i-ml-nlt" id="prod-WTA5_13X">
|
||
<emu-t>[</emu-t>
|
||
<emu-nt id="_ref_24407"><a href="text-processing.html#prod-ClassContents">ClassContents</a></emu-nt>
|
||
<emu-t>]</emu-t>
|
||
</emu-rhs>
|
||
</emu-production>
|
||
</emu-grammar>
|
||
<emu-alg><ol><li>Let <var>A</var> be <emu-xref aoid="CompileToCharSet" id="_ref_12090"><a href="text-processing.html#sec-compiletocharset">CompileToCharSet</a></emu-xref> of <emu-nt id="_ref_24408"><a href="text-processing.html#prod-ClassContents">ClassContents</a></emu-nt> with argument <var>rer</var>.</li><li>Return the <emu-xref href="#sec-list-and-record-specification-type" id="_ref_12091"><a href="ecmascript-data-types-and-values.html#sec-list-and-record-specification-type">Record</a></emu-xref> { <var class="field">[[CharSet]]</var>: <var>A</var>, <var class="field">[[Invert]]</var>: <emu-val>false</emu-val> }.</li></ol></emu-alg>
|
||
<emu-grammar><emu-production name="CharacterClass" type="lexical" collapsed="">
|
||
<emu-nt><a href="text-processing.html#prod-CharacterClass">CharacterClass</a></emu-nt> <emu-geq>::</emu-geq> <emu-rhs a="d-swr39f" id="prod-C4IeNsQH">
|
||
<emu-t>[^</emu-t>
|
||
<emu-nt id="_ref_24409"><a href="text-processing.html#prod-ClassContents">ClassContents</a></emu-nt>
|
||
<emu-t>]</emu-t>
|
||
</emu-rhs>
|
||
</emu-production>
|
||
</emu-grammar>
|
||
<emu-alg><ol><li>Let <var>A</var> be <emu-xref aoid="CompileToCharSet" id="_ref_12092"><a href="text-processing.html#sec-compiletocharset">CompileToCharSet</a></emu-xref> of <emu-nt id="_ref_24410"><a href="text-processing.html#prod-ClassContents">ClassContents</a></emu-nt> with argument <var>rer</var>.</li><li>If <var>rer</var>.<var class="field">[[UnicodeSets]]</var> is <emu-val>true</emu-val>, then<ol><li>Return the <emu-xref href="#sec-list-and-record-specification-type" id="_ref_12093"><a href="ecmascript-data-types-and-values.html#sec-list-and-record-specification-type">Record</a></emu-xref> { <var class="field">[[CharSet]]</var>: <emu-xref aoid="CharacterComplement" id="_ref_12094"><a href="text-processing.html#sec-charactercomplement">CharacterComplement</a></emu-xref>(<var>rer</var>, <var>A</var>), <var class="field">[[Invert]]</var>: <emu-val>false</emu-val> }.</li></ol></li><li>Return the <emu-xref href="#sec-list-and-record-specification-type" id="_ref_12095"><a href="ecmascript-data-types-and-values.html#sec-list-and-record-specification-type">Record</a></emu-xref> { <var class="field">[[CharSet]]</var>: <var>A</var>, <var class="field">[[Invert]]</var>: <emu-val>true</emu-val> }.</li></ol></emu-alg>
|
||
</emu-clause>
|
||
|
||
<emu-clause id="sec-compiletocharset" type="sdo" oldids="sec-classranges,sec-nonemptyclassranges,sec-nonemptyclassrangesnodash,sec-classatom,sec-classatomnodash,sec-classescape,sec-characterclassescape" aoid="CompileToCharSet"><span id="sec-characterclassescape"></span><span id="sec-classescape"></span><span id="sec-classatomnodash"></span><span id="sec-classatom"></span><span id="sec-nonemptyclassrangesnodash"></span><span id="sec-nonemptyclassranges"></span><span id="sec-classranges"></span>
|
||
<h1><span class="secnum">22.2.2.9</span> Runtime Semantics: CompileToCharSet</h1>
|
||
<p>The <emu-xref href="#sec-algorithm-conventions-syntax-directed-operations" id="_ref_12096"><a href="notational-conventions.html#sec-algorithm-conventions-syntax-directed-operations">syntax-directed operation</a></emu-xref> CompileToCharSet takes argument <var>rer</var> (a <emu-xref href="#sec-regexp-records" id="_ref_12097"><a href="text-processing.html#sec-regexp-records">RegExp Record</a></emu-xref>) and returns a <emu-xref href="#pattern-charset" id="_ref_12098"><a href="text-processing.html#pattern-charset">CharSet</a></emu-xref>.</p>
|
||
<emu-note><span class="note">Note 1</span><div class="note-contents">
|
||
<p>This section is amended in <emu-xref href="#sec-compiletocharset-annexb" id="_ref_696"><a href="additional-ecmascript-features-for-web-browsers.html#sec-compiletocharset-annexb">B.1.2.8</a></emu-xref>.</p>
|
||
</div></emu-note>
|
||
|
||
<!-- ClassContents -->
|
||
<p>It is defined piecewise over the following productions:</p>
|
||
<emu-grammar><emu-production name="ClassContents" type="lexical" collapsed="">
|
||
<emu-nt><a href="text-processing.html#prod-ClassContents">ClassContents</a></emu-nt> <emu-geq>::</emu-geq> <emu-rhs a="n7nathbb" id="prod-JD0n1C2m"><emu-gann>[empty]</emu-gann></emu-rhs>
|
||
</emu-production>
|
||
</emu-grammar>
|
||
<emu-alg><ol><li>Return the empty <emu-xref href="#pattern-charset" id="_ref_12099"><a href="text-processing.html#pattern-charset">CharSet</a></emu-xref>.</li></ol></emu-alg>
|
||
|
||
<!-- NonemptyClassRanges -->
|
||
<emu-grammar><emu-production name="NonemptyClassRanges" type="lexical" collapsed="">
|
||
<emu-nt><a href="text-processing.html#prod-NonemptyClassRanges">NonemptyClassRanges</a></emu-nt> <emu-geq>::</emu-geq> <emu-rhs a="9bczlwfd" id="prod-v8F30MhJ">
|
||
<emu-nt id="_ref_24411"><a href="text-processing.html#prod-ClassAtom">ClassAtom</a></emu-nt>
|
||
<emu-nt id="_ref_24412"><a href="text-processing.html#prod-NonemptyClassRangesNoDash">NonemptyClassRangesNoDash</a></emu-nt>
|
||
</emu-rhs>
|
||
</emu-production>
|
||
</emu-grammar>
|
||
<emu-alg><ol><li>Let <var>A</var> be <emu-xref aoid="CompileToCharSet" id="_ref_12100"><a href="text-processing.html#sec-compiletocharset">CompileToCharSet</a></emu-xref> of <emu-nt id="_ref_24413"><a href="text-processing.html#prod-ClassAtom">ClassAtom</a></emu-nt> with argument <var>rer</var>.</li><li>Let <var>B</var> be <emu-xref aoid="CompileToCharSet" id="_ref_12101"><a href="text-processing.html#sec-compiletocharset">CompileToCharSet</a></emu-xref> of <emu-nt id="_ref_24414"><a href="text-processing.html#prod-NonemptyClassRangesNoDash">NonemptyClassRangesNoDash</a></emu-nt> with argument <var>rer</var>.</li><li>Return the union of <emu-xref href="#pattern-charset" id="_ref_12102"><a href="text-processing.html#pattern-charset">CharSets</a></emu-xref> <var>A</var> and <var>B</var>.</li></ol></emu-alg>
|
||
<emu-grammar><emu-production name="NonemptyClassRanges" type="lexical" collapsed="">
|
||
<emu-nt><a href="text-processing.html#prod-NonemptyClassRanges">NonemptyClassRanges</a></emu-nt> <emu-geq>::</emu-geq> <emu-rhs a="2bs-sw8o" id="prod-3Hff_hWr">
|
||
<emu-nt id="_ref_24415"><a href="text-processing.html#prod-ClassAtom">ClassAtom</a></emu-nt>
|
||
<emu-t>-</emu-t>
|
||
<emu-nt id="_ref_24416"><a href="text-processing.html#prod-ClassAtom">ClassAtom</a></emu-nt>
|
||
<emu-nt id="_ref_24417"><a href="text-processing.html#prod-ClassContents">ClassContents</a></emu-nt>
|
||
</emu-rhs>
|
||
</emu-production>
|
||
</emu-grammar>
|
||
<emu-alg><ol><li>Let <var>A</var> be <emu-xref aoid="CompileToCharSet" id="_ref_12103"><a href="text-processing.html#sec-compiletocharset">CompileToCharSet</a></emu-xref> of the first <emu-nt id="_ref_24418"><a href="text-processing.html#prod-ClassAtom">ClassAtom</a></emu-nt> with argument <var>rer</var>.</li><li>Let <var>B</var> be <emu-xref aoid="CompileToCharSet" id="_ref_12104"><a href="text-processing.html#sec-compiletocharset">CompileToCharSet</a></emu-xref> of the second <emu-nt id="_ref_24419"><a href="text-processing.html#prod-ClassAtom">ClassAtom</a></emu-nt> with argument <var>rer</var>.</li><li>Let <var>C</var> be <emu-xref aoid="CompileToCharSet" id="_ref_12105"><a href="text-processing.html#sec-compiletocharset">CompileToCharSet</a></emu-xref> of <emu-nt id="_ref_24420"><a href="text-processing.html#prod-ClassContents">ClassContents</a></emu-nt> with argument <var>rer</var>.</li><li>Let <var>D</var> be <emu-xref aoid="CharacterRange" id="_ref_12106"><a href="text-processing.html#sec-runtime-semantics-characterrange-abstract-operation">CharacterRange</a></emu-xref>(<var>A</var>, <var>B</var>).</li><li>Return the union of <var>D</var> and <var>C</var>.</li></ol></emu-alg>
|
||
|
||
<!-- NonemptyClassRangesNoDash -->
|
||
<emu-grammar><emu-production name="NonemptyClassRangesNoDash" type="lexical" collapsed="">
|
||
<emu-nt><a href="text-processing.html#prod-NonemptyClassRangesNoDash">NonemptyClassRangesNoDash</a></emu-nt> <emu-geq>::</emu-geq> <emu-rhs a="z2ljibgz" id="prod-F2f_obS_">
|
||
<emu-nt id="_ref_24421"><a href="text-processing.html#prod-ClassAtomNoDash">ClassAtomNoDash</a></emu-nt>
|
||
<emu-nt id="_ref_24422"><a href="text-processing.html#prod-NonemptyClassRangesNoDash">NonemptyClassRangesNoDash</a></emu-nt>
|
||
</emu-rhs>
|
||
</emu-production>
|
||
</emu-grammar>
|
||
<emu-alg><ol><li>Let <var>A</var> be <emu-xref aoid="CompileToCharSet" id="_ref_12107"><a href="text-processing.html#sec-compiletocharset">CompileToCharSet</a></emu-xref> of <emu-nt id="_ref_24423"><a href="text-processing.html#prod-ClassAtomNoDash">ClassAtomNoDash</a></emu-nt> with argument <var>rer</var>.</li><li>Let <var>B</var> be <emu-xref aoid="CompileToCharSet" id="_ref_12108"><a href="text-processing.html#sec-compiletocharset">CompileToCharSet</a></emu-xref> of <emu-nt id="_ref_24424"><a href="text-processing.html#prod-NonemptyClassRangesNoDash">NonemptyClassRangesNoDash</a></emu-nt> with argument <var>rer</var>.</li><li>Return the union of <emu-xref href="#pattern-charset" id="_ref_12109"><a href="text-processing.html#pattern-charset">CharSets</a></emu-xref> <var>A</var> and <var>B</var>.</li></ol></emu-alg>
|
||
<emu-grammar><emu-production name="NonemptyClassRangesNoDash" type="lexical" collapsed="">
|
||
<emu-nt><a href="text-processing.html#prod-NonemptyClassRangesNoDash">NonemptyClassRangesNoDash</a></emu-nt> <emu-geq>::</emu-geq> <emu-rhs a="udwlha-v" id="prod-m3mx3xme">
|
||
<emu-nt id="_ref_24425"><a href="text-processing.html#prod-ClassAtomNoDash">ClassAtomNoDash</a></emu-nt>
|
||
<emu-t>-</emu-t>
|
||
<emu-nt id="_ref_24426"><a href="text-processing.html#prod-ClassAtom">ClassAtom</a></emu-nt>
|
||
<emu-nt id="_ref_24427"><a href="text-processing.html#prod-ClassContents">ClassContents</a></emu-nt>
|
||
</emu-rhs>
|
||
</emu-production>
|
||
</emu-grammar>
|
||
<emu-alg><ol><li>Let <var>A</var> be <emu-xref aoid="CompileToCharSet" id="_ref_12110"><a href="text-processing.html#sec-compiletocharset">CompileToCharSet</a></emu-xref> of <emu-nt id="_ref_24428"><a href="text-processing.html#prod-ClassAtomNoDash">ClassAtomNoDash</a></emu-nt> with argument <var>rer</var>.</li><li>Let <var>B</var> be <emu-xref aoid="CompileToCharSet" id="_ref_12111"><a href="text-processing.html#sec-compiletocharset">CompileToCharSet</a></emu-xref> of <emu-nt id="_ref_24429"><a href="text-processing.html#prod-ClassAtom">ClassAtom</a></emu-nt> with argument <var>rer</var>.</li><li>Let <var>C</var> be <emu-xref aoid="CompileToCharSet" id="_ref_12112"><a href="text-processing.html#sec-compiletocharset">CompileToCharSet</a></emu-xref> of <emu-nt id="_ref_24430"><a href="text-processing.html#prod-ClassContents">ClassContents</a></emu-nt> with argument <var>rer</var>.</li><li>Let <var>D</var> be <emu-xref aoid="CharacterRange" id="_ref_12113"><a href="text-processing.html#sec-runtime-semantics-characterrange-abstract-operation">CharacterRange</a></emu-xref>(<var>A</var>, <var>B</var>).</li><li>Return the union of <var>D</var> and <var>C</var>.</li></ol></emu-alg>
|
||
<emu-note><span class="note">Note 2</span><div class="note-contents">
|
||
<p><emu-nt id="_ref_24431"><a href="text-processing.html#prod-ClassContents">ClassContents</a></emu-nt> can expand into a single <emu-nt id="_ref_24432"><a href="text-processing.html#prod-ClassAtom">ClassAtom</a></emu-nt> and/or ranges of two <emu-nt id="_ref_24433"><a href="text-processing.html#prod-ClassAtom">ClassAtom</a></emu-nt> separated by dashes. In the latter case the <emu-nt id="_ref_24434"><a href="text-processing.html#prod-ClassContents">ClassContents</a></emu-nt> includes all characters between the first <emu-nt id="_ref_24435"><a href="text-processing.html#prod-ClassAtom">ClassAtom</a></emu-nt> and the second <emu-nt id="_ref_24436"><a href="text-processing.html#prod-ClassAtom">ClassAtom</a></emu-nt>, inclusive; an error occurs if either <emu-nt id="_ref_24437"><a href="text-processing.html#prod-ClassAtom">ClassAtom</a></emu-nt> does not represent a single character (for example, if one is \w) or if the first <emu-nt id="_ref_24438"><a href="text-processing.html#prod-ClassAtom">ClassAtom</a></emu-nt>'s character value is strictly greater than the second <emu-nt id="_ref_24439"><a href="text-processing.html#prod-ClassAtom">ClassAtom</a></emu-nt>'s character value.</p>
|
||
</div></emu-note>
|
||
<emu-note><span class="note">Note 3</span><div class="note-contents">
|
||
<p>Even if the pattern ignores case, the case of the two ends of a range is significant in determining which characters belong to the range. Thus, for example, the pattern <code>/[E-F]/i</code> matches only the letters <code>E</code>, <code>F</code>, <code>e</code>, and <code>f</code>, while the pattern <code>/[E-f]/i</code> matches all uppercase and lowercase letters in the Unicode Basic Latin block as well as the symbols <code>[</code>, <code>\</code>, <code>]</code>, <code>^</code>, <code>_</code>, and <code>`</code>.</p>
|
||
</div></emu-note>
|
||
<emu-note><span class="note">Note 4</span><div class="note-contents">
|
||
<p>A <code>-</code> character can be treated literally or it can denote a range. It is treated literally if it is the first or last character of <emu-nt id="_ref_24440"><a href="text-processing.html#prod-ClassContents">ClassContents</a></emu-nt>, the beginning or end limit of a range specification, or immediately follows a range specification.</p>
|
||
</div></emu-note>
|
||
|
||
<!-- ClassAtom -->
|
||
<emu-grammar><emu-production name="ClassAtom" type="lexical" collapsed="">
|
||
<emu-nt><a href="text-processing.html#prod-ClassAtom">ClassAtom</a></emu-nt> <emu-geq>::</emu-geq> <emu-rhs a="byslh4l8" id="prod-v1pSxa5N"><emu-t>-</emu-t></emu-rhs>
|
||
</emu-production>
|
||
</emu-grammar>
|
||
<emu-alg><ol><li>Return the <emu-xref href="#pattern-charset" id="_ref_12114"><a href="text-processing.html#pattern-charset">CharSet</a></emu-xref> containing the single character <code>-</code> U+002D (HYPHEN-MINUS).</li></ol></emu-alg>
|
||
|
||
<!-- ClassAtomNoDash -->
|
||
<emu-grammar><emu-production name="ClassAtomNoDash" type="lexical" collapsed="">
|
||
<emu-nt><a href="text-processing.html#prod-ClassAtomNoDash">ClassAtomNoDash</a></emu-nt> <emu-geq>::</emu-geq> <emu-rhs a="7n5ukjeb" id="prod-XIQ-jH7Q"><emu-nt id="_ref_24441"><a href="ecmascript-language-source-code.html#prod-SourceCharacter">SourceCharacter</a></emu-nt> <emu-gmod>but not one of <emu-t>\</emu-t> or <emu-t>]</emu-t> or <emu-t>-</emu-t></emu-gmod></emu-rhs>
|
||
</emu-production>
|
||
</emu-grammar>
|
||
<emu-alg><ol><li>Return the <emu-xref href="#pattern-charset" id="_ref_12115"><a href="text-processing.html#pattern-charset">CharSet</a></emu-xref> containing the character matched by <emu-nt id="_ref_24442"><a href="ecmascript-language-source-code.html#prod-SourceCharacter">SourceCharacter</a></emu-nt>.</li></ol></emu-alg>
|
||
|
||
<!-- ClassEscape -->
|
||
<emu-grammar><emu-production name="ClassEscape" type="lexical">
|
||
<emu-nt><a href="text-processing.html#prod-ClassEscape">ClassEscape</a></emu-nt> <emu-geq>::</emu-geq> <emu-rhs a="ayxoiyyq" id="prod-y4BsoD9c">
|
||
<emu-t>b</emu-t>
|
||
</emu-rhs>
|
||
<emu-rhs a="byslh4l8" id="prod-dYEaUVMZ">
|
||
<emu-t>-</emu-t>
|
||
</emu-rhs>
|
||
<emu-rhs a="fjarvpc8" id="prod--6UgQqmj">
|
||
<emu-nt id="_ref_24443"><a href="text-processing.html#prod-CharacterEscape">CharacterEscape</a></emu-nt>
|
||
</emu-rhs>
|
||
</emu-production>
|
||
</emu-grammar>
|
||
<emu-alg><ol><li>Let <var>cv</var> be the <emu-xref aoid="CharacterValue" id="_ref_12116"><a href="text-processing.html#sec-patterns-static-semantics-character-value">CharacterValue</a></emu-xref> of this <emu-nt id="_ref_24444"><a href="text-processing.html#prod-ClassEscape">ClassEscape</a></emu-nt>.</li><li>Let <var>c</var> be the character whose character value is <var>cv</var>.</li><li>Return the <emu-xref href="#pattern-charset" id="_ref_12117"><a href="text-processing.html#pattern-charset">CharSet</a></emu-xref> containing the single character <var>c</var>.</li></ol></emu-alg>
|
||
<emu-note><span class="note">Note 5</span><div class="note-contents">
|
||
<p>A <emu-nt id="_ref_24445"><a href="text-processing.html#prod-ClassAtom">ClassAtom</a></emu-nt> can use any of the escape sequences that are allowed in the rest of the regular expression except for <code>\b</code>, <code>\B</code>, and backreferences. Inside a <emu-nt id="_ref_24446"><a href="text-processing.html#prod-CharacterClass">CharacterClass</a></emu-nt>, <code>\b</code> means the backspace character, while <code>\B</code> and backreferences raise errors. Using a backreference inside a <emu-nt id="_ref_24447"><a href="text-processing.html#prod-ClassAtom">ClassAtom</a></emu-nt> causes an error.</p>
|
||
</div></emu-note>
|
||
|
||
<!-- CharacterClassEscape -->
|
||
<emu-grammar><emu-production name="CharacterClassEscape" type="lexical" collapsed="">
|
||
<emu-nt><a href="text-processing.html#prod-CharacterClassEscape">CharacterClassEscape</a></emu-nt> <emu-geq>::</emu-geq> <emu-rhs a="8pmnkw2i" id="prod-E23U4UCW"><emu-t>d</emu-t></emu-rhs>
|
||
</emu-production>
|
||
</emu-grammar>
|
||
<emu-alg><ol><li>Return the ten-element <emu-xref href="#pattern-charset" id="_ref_12118"><a href="text-processing.html#pattern-charset">CharSet</a></emu-xref> containing the characters <code>0</code>, <code>1</code>, <code>2</code>, <code>3</code>, <code>4</code>, <code>5</code>, <code>6</code>, <code>7</code>, <code>8</code>, and <code>9</code>.</li></ol></emu-alg>
|
||
<emu-grammar><emu-production name="CharacterClassEscape" type="lexical" collapsed="">
|
||
<emu-nt><a href="text-processing.html#prod-CharacterClassEscape">CharacterClassEscape</a></emu-nt> <emu-geq>::</emu-geq> <emu-rhs a="kzsugx0d" id="prod-CJ70Staj"><emu-t>D</emu-t></emu-rhs>
|
||
</emu-production>
|
||
</emu-grammar>
|
||
<emu-alg><ol><li>Let <var>S</var> be the <emu-xref href="#pattern-charset" id="_ref_12119"><a href="text-processing.html#pattern-charset">CharSet</a></emu-xref> returned by <emu-grammar><emu-production name="CharacterClassEscape" type="lexical" collapsed="" class=" inline">
|
||
<emu-nt><a href="text-processing.html#prod-CharacterClassEscape">CharacterClassEscape</a></emu-nt> <emu-geq>::</emu-geq> <emu-rhs a="8pmnkw2i"><emu-t>d</emu-t></emu-rhs>
|
||
</emu-production>
|
||
</emu-grammar>.</li><li>Return <emu-xref aoid="CharacterComplement" id="_ref_12120"><a href="text-processing.html#sec-charactercomplement">CharacterComplement</a></emu-xref>(<var>rer</var>, <var>S</var>).</li></ol></emu-alg>
|
||
<emu-grammar><emu-production name="CharacterClassEscape" type="lexical" collapsed="">
|
||
<emu-nt><a href="text-processing.html#prod-CharacterClassEscape">CharacterClassEscape</a></emu-nt> <emu-geq>::</emu-geq> <emu-rhs a="w5xsbsk3" id="prod-4qp2L35t"><emu-t>s</emu-t></emu-rhs>
|
||
</emu-production>
|
||
</emu-grammar>
|
||
<emu-alg><ol><li>Return the <emu-xref href="#pattern-charset" id="_ref_12121"><a href="text-processing.html#pattern-charset">CharSet</a></emu-xref> containing all characters corresponding to a code point on the right-hand side of the <emu-nt id="_ref_24448"><a href="ecmascript-language-lexical-grammar.html#prod-WhiteSpace">WhiteSpace</a></emu-nt> or <emu-nt id="_ref_24449"><a href="ecmascript-language-lexical-grammar.html#prod-LineTerminator">LineTerminator</a></emu-nt> productions.</li></ol></emu-alg>
|
||
<emu-grammar><emu-production name="CharacterClassEscape" type="lexical" collapsed="">
|
||
<emu-nt><a href="text-processing.html#prod-CharacterClassEscape">CharacterClassEscape</a></emu-nt> <emu-geq>::</emu-geq> <emu-rhs a="avlpsekd" id="prod-sOQsJGFN"><emu-t>S</emu-t></emu-rhs>
|
||
</emu-production>
|
||
</emu-grammar>
|
||
<emu-alg><ol><li>Let <var>S</var> be the <emu-xref href="#pattern-charset" id="_ref_12122"><a href="text-processing.html#pattern-charset">CharSet</a></emu-xref> returned by <emu-grammar><emu-production name="CharacterClassEscape" type="lexical" collapsed="" class=" inline">
|
||
<emu-nt><a href="text-processing.html#prod-CharacterClassEscape">CharacterClassEscape</a></emu-nt> <emu-geq>::</emu-geq> <emu-rhs a="w5xsbsk3"><emu-t>s</emu-t></emu-rhs>
|
||
</emu-production>
|
||
</emu-grammar>.</li><li>Return <emu-xref aoid="CharacterComplement" id="_ref_12123"><a href="text-processing.html#sec-charactercomplement">CharacterComplement</a></emu-xref>(<var>rer</var>, <var>S</var>).</li></ol></emu-alg>
|
||
<emu-grammar><emu-production name="CharacterClassEscape" type="lexical" collapsed="">
|
||
<emu-nt><a href="text-processing.html#prod-CharacterClassEscape">CharacterClassEscape</a></emu-nt> <emu-geq>::</emu-geq> <emu-rhs a="lytism1a" id="prod-yVuyKzZ7"><emu-t>w</emu-t></emu-rhs>
|
||
</emu-production>
|
||
</emu-grammar>
|
||
<emu-alg><ol><li>Return <emu-xref aoid="MaybeSimpleCaseFolding" id="_ref_12124"><a href="text-processing.html#sec-maybesimplecasefolding">MaybeSimpleCaseFolding</a></emu-xref>(<var>rer</var>, <emu-xref aoid="WordCharacters" id="_ref_12125"><a href="text-processing.html#sec-wordcharacters">WordCharacters</a></emu-xref>(<var>rer</var>)).</li></ol></emu-alg>
|
||
<emu-grammar><emu-production name="CharacterClassEscape" type="lexical" collapsed="">
|
||
<emu-nt><a href="text-processing.html#prod-CharacterClassEscape">CharacterClassEscape</a></emu-nt> <emu-geq>::</emu-geq> <emu-rhs a="rhxouzu-" id="prod-3TNl1K-Z"><emu-t>W</emu-t></emu-rhs>
|
||
</emu-production>
|
||
</emu-grammar>
|
||
<emu-alg><ol><li>Let <var>S</var> be the <emu-xref href="#pattern-charset" id="_ref_12126"><a href="text-processing.html#pattern-charset">CharSet</a></emu-xref> returned by <emu-grammar><emu-production name="CharacterClassEscape" type="lexical" collapsed="" class=" inline">
|
||
<emu-nt><a href="text-processing.html#prod-CharacterClassEscape">CharacterClassEscape</a></emu-nt> <emu-geq>::</emu-geq> <emu-rhs a="lytism1a"><emu-t>w</emu-t></emu-rhs>
|
||
</emu-production>
|
||
</emu-grammar>.</li><li>Return <emu-xref aoid="CharacterComplement" id="_ref_12127"><a href="text-processing.html#sec-charactercomplement">CharacterComplement</a></emu-xref>(<var>rer</var>, <var>S</var>).</li></ol></emu-alg>
|
||
<emu-grammar><emu-production name="CharacterClassEscape" type="lexical" collapsed="">
|
||
<emu-nt><a href="text-processing.html#prod-CharacterClassEscape">CharacterClassEscape</a></emu-nt> <emu-geq>::</emu-geq> <emu-rhs a="w6blst1q" id="prod-kc86cCn-">
|
||
<emu-t>p{</emu-t>
|
||
<emu-nt id="_ref_24450"><a href="text-processing.html#prod-UnicodePropertyValueExpression">UnicodePropertyValueExpression</a></emu-nt>
|
||
<emu-t>}</emu-t>
|
||
</emu-rhs>
|
||
</emu-production>
|
||
</emu-grammar>
|
||
<emu-alg><ol><li>Return <emu-xref aoid="CompileToCharSet" id="_ref_12128"><a href="text-processing.html#sec-compiletocharset">CompileToCharSet</a></emu-xref> of <emu-nt id="_ref_24451"><a href="text-processing.html#prod-UnicodePropertyValueExpression">UnicodePropertyValueExpression</a></emu-nt> with argument <var>rer</var>.</li></ol></emu-alg>
|
||
<emu-grammar><emu-production name="CharacterClassEscape" type="lexical" collapsed="">
|
||
<emu-nt><a href="text-processing.html#prod-CharacterClassEscape">CharacterClassEscape</a></emu-nt> <emu-geq>::</emu-geq> <emu-rhs a="4og7ke5v" id="prod-rM2HtPxJ">
|
||
<emu-t>P{</emu-t>
|
||
<emu-nt id="_ref_24452"><a href="text-processing.html#prod-UnicodePropertyValueExpression">UnicodePropertyValueExpression</a></emu-nt>
|
||
<emu-t>}</emu-t>
|
||
</emu-rhs>
|
||
</emu-production>
|
||
</emu-grammar>
|
||
<emu-alg><ol><li>Let <var>S</var> be <emu-xref aoid="CompileToCharSet" id="_ref_12129"><a href="text-processing.html#sec-compiletocharset">CompileToCharSet</a></emu-xref> of <emu-nt id="_ref_24453"><a href="text-processing.html#prod-UnicodePropertyValueExpression">UnicodePropertyValueExpression</a></emu-nt> with argument <var>rer</var>.</li><li><emu-xref href="#assert" id="_ref_12130"><a href="notational-conventions.html#assert">Assert</a></emu-xref>: <var>S</var> contains only single code points.</li><li>Return <emu-xref aoid="CharacterComplement" id="_ref_12131"><a href="text-processing.html#sec-charactercomplement">CharacterComplement</a></emu-xref>(<var>rer</var>, <var>S</var>).</li></ol></emu-alg>
|
||
<emu-grammar><emu-production name="UnicodePropertyValueExpression" type="lexical" collapsed="">
|
||
<emu-nt><a href="text-processing.html#prod-UnicodePropertyValueExpression">UnicodePropertyValueExpression</a></emu-nt> <emu-geq>::</emu-geq> <emu-rhs a="sr3kbwzj" id="prod-5_vYUeM-">
|
||
<emu-nt id="_ref_24454"><a href="text-processing.html#prod-UnicodePropertyName">UnicodePropertyName</a></emu-nt>
|
||
<emu-t>=</emu-t>
|
||
<emu-nt id="_ref_24455"><a href="text-processing.html#prod-UnicodePropertyValue">UnicodePropertyValue</a></emu-nt>
|
||
</emu-rhs>
|
||
</emu-production>
|
||
</emu-grammar>
|
||
<emu-alg><ol><li>Let <var>ps</var> be the <emu-xref href="#sec-algorithm-conventions-syntax-directed-operations" id="_ref_12132"><a href="notational-conventions.html#sec-algorithm-conventions-syntax-directed-operations">source text matched by</a></emu-xref> <emu-nt id="_ref_24456"><a href="text-processing.html#prod-UnicodePropertyName">UnicodePropertyName</a></emu-nt>.</li><li>Let <var>p</var> be <emu-xref aoid="UnicodeMatchProperty" id="_ref_12133"><a href="text-processing.html#sec-runtime-semantics-unicodematchproperty-p">UnicodeMatchProperty</a></emu-xref>(<var>rer</var>, <var>ps</var>).</li><li><emu-xref href="#assert" id="_ref_12134"><a href="notational-conventions.html#assert">Assert</a></emu-xref>: <var>p</var> is a <emu-not-ref>Unicode property name</emu-not-ref> or property alias listed in the “<emu-not-ref>Property name and aliases</emu-not-ref>” column of <emu-xref href="#table-nonbinary-unicode-properties" id="_ref_697"><a href="text-processing.html#table-nonbinary-unicode-properties">Table 64</a></emu-xref>.</li><li>Let <var>vs</var> be the <emu-xref href="#sec-algorithm-conventions-syntax-directed-operations" id="_ref_12135"><a href="notational-conventions.html#sec-algorithm-conventions-syntax-directed-operations">source text matched by</a></emu-xref> <emu-nt id="_ref_24457"><a href="text-processing.html#prod-UnicodePropertyValue">UnicodePropertyValue</a></emu-nt>.</li><li>Let <var>v</var> be <emu-xref aoid="UnicodeMatchPropertyValue" id="_ref_12136"><a href="text-processing.html#sec-runtime-semantics-unicodematchpropertyvalue-p-v">UnicodeMatchPropertyValue</a></emu-xref>(<var>p</var>, <var>vs</var>).</li><li>Let <var>A</var> be the <emu-xref href="#pattern-charset" id="_ref_12137"><a href="text-processing.html#pattern-charset">CharSet</a></emu-xref> containing all Unicode code points whose character database definition includes the property <var>p</var> with value <var>v</var>.</li><li>Return <emu-xref aoid="MaybeSimpleCaseFolding" id="_ref_12138"><a href="text-processing.html#sec-maybesimplecasefolding">MaybeSimpleCaseFolding</a></emu-xref>(<var>rer</var>, <var>A</var>).</li></ol></emu-alg>
|
||
<emu-grammar><emu-production name="UnicodePropertyValueExpression" type="lexical" collapsed="">
|
||
<emu-nt><a href="text-processing.html#prod-UnicodePropertyValueExpression">UnicodePropertyValueExpression</a></emu-nt> <emu-geq>::</emu-geq> <emu-rhs a="jdlbklv9" id="prod-JU4eVWl0"><emu-nt id="_ref_24458"><a href="text-processing.html#prod-LoneUnicodePropertyNameOrValue">LoneUnicodePropertyNameOrValue</a></emu-nt></emu-rhs>
|
||
</emu-production>
|
||
</emu-grammar>
|
||
<emu-alg><ol><li>Let <var>s</var> be the <emu-xref href="#sec-algorithm-conventions-syntax-directed-operations" id="_ref_12139"><a href="notational-conventions.html#sec-algorithm-conventions-syntax-directed-operations">source text matched by</a></emu-xref> <emu-nt id="_ref_24459"><a href="text-processing.html#prod-LoneUnicodePropertyNameOrValue">LoneUnicodePropertyNameOrValue</a></emu-nt>.</li><li>If <emu-xref aoid="UnicodeMatchPropertyValue" id="_ref_12140"><a href="text-processing.html#sec-runtime-semantics-unicodematchpropertyvalue-p-v">UnicodeMatchPropertyValue</a></emu-xref>(<code>General_Category</code>, <var>s</var>) is a Unicode property value or property value alias for the General_Category (gc) property listed in <a href="https://unicode.org/Public/UCD/latest/ucd/PropertyValueAliases.txt"><code>PropertyValueAliases.txt</code></a>, then<ol><li>Return the <emu-xref href="#pattern-charset" id="_ref_12141"><a href="text-processing.html#pattern-charset">CharSet</a></emu-xref> containing all Unicode code points whose character database definition includes the property “General_Category” with value <var>s</var>.</li></ol></li><li>Let <var>p</var> be <emu-xref aoid="UnicodeMatchProperty" id="_ref_12142"><a href="text-processing.html#sec-runtime-semantics-unicodematchproperty-p">UnicodeMatchProperty</a></emu-xref>(<var>rer</var>, <var>s</var>).</li><li><emu-xref href="#assert" id="_ref_12143"><a href="notational-conventions.html#assert">Assert</a></emu-xref>: <var>p</var> is a binary Unicode property or binary property alias listed in the “<emu-not-ref>Property name and aliases</emu-not-ref>” column of <emu-xref href="#table-binary-unicode-properties" id="_ref_698"><a href="text-processing.html#table-binary-unicode-properties">Table 65</a></emu-xref>, or a binary Unicode property of strings listed in the “<emu-not-ref>Property name</emu-not-ref>” column of <emu-xref href="#table-binary-unicode-properties-of-strings" id="_ref_699"><a href="text-processing.html#table-binary-unicode-properties-of-strings">Table 66</a></emu-xref>.</li><li>Let <var>A</var> be the <emu-xref href="#pattern-charset" id="_ref_12144"><a href="text-processing.html#pattern-charset">CharSet</a></emu-xref> containing all CharSetElements whose character database definition includes the property <var>p</var> with value “True”.</li><li>Return <emu-xref aoid="MaybeSimpleCaseFolding" id="_ref_12145"><a href="text-processing.html#sec-maybesimplecasefolding">MaybeSimpleCaseFolding</a></emu-xref>(<var>rer</var>, <var>A</var>).</li></ol></emu-alg>
|
||
|
||
<!-- ClassUnion -->
|
||
<emu-grammar><emu-production name="ClassUnion" type="lexical" collapsed="">
|
||
<emu-nt><a href="text-processing.html#prod-ClassUnion">ClassUnion</a></emu-nt> <emu-geq>::</emu-geq> <emu-rhs a="lvavyv54" id="prod-9tLGzF96">
|
||
<emu-nt id="_ref_24460"><a href="text-processing.html#prod-ClassSetRange">ClassSetRange</a></emu-nt>
|
||
<emu-nt optional="" id="_ref_24461"><a href="text-processing.html#prod-ClassUnion">ClassUnion</a><emu-mods><emu-opt>opt</emu-opt></emu-mods></emu-nt>
|
||
</emu-rhs>
|
||
</emu-production>
|
||
</emu-grammar>
|
||
<emu-alg><ol><li>Let <var>A</var> be <emu-xref aoid="CompileToCharSet" id="_ref_12146"><a href="text-processing.html#sec-compiletocharset">CompileToCharSet</a></emu-xref> of <emu-nt id="_ref_24462"><a href="text-processing.html#prod-ClassSetRange">ClassSetRange</a></emu-nt> with argument <var>rer</var>.</li><li>If <emu-nt id="_ref_24463"><a href="text-processing.html#prod-ClassUnion">ClassUnion</a></emu-nt> is present, then<ol><li>Let <var>B</var> be <emu-xref aoid="CompileToCharSet" id="_ref_12147"><a href="text-processing.html#sec-compiletocharset">CompileToCharSet</a></emu-xref> of <emu-nt id="_ref_24464"><a href="text-processing.html#prod-ClassUnion">ClassUnion</a></emu-nt> with argument <var>rer</var>.</li><li>Return the union of <emu-xref href="#pattern-charset" id="_ref_12148"><a href="text-processing.html#pattern-charset">CharSets</a></emu-xref> <var>A</var> and <var>B</var>.</li></ol></li><li>Return <var>A</var>.</li></ol></emu-alg>
|
||
<emu-grammar><emu-production name="ClassUnion" type="lexical" collapsed="">
|
||
<emu-nt><a href="text-processing.html#prod-ClassUnion">ClassUnion</a></emu-nt> <emu-geq>::</emu-geq> <emu-rhs a="ga57bqew" id="prod-x0IzZQcL">
|
||
<emu-nt id="_ref_24465"><a href="text-processing.html#prod-ClassSetOperand">ClassSetOperand</a></emu-nt>
|
||
<emu-nt optional="" id="_ref_24466"><a href="text-processing.html#prod-ClassUnion">ClassUnion</a><emu-mods><emu-opt>opt</emu-opt></emu-mods></emu-nt>
|
||
</emu-rhs>
|
||
</emu-production>
|
||
</emu-grammar>
|
||
<emu-alg><ol><li>Let <var>A</var> be <emu-xref aoid="CompileToCharSet" id="_ref_12149"><a href="text-processing.html#sec-compiletocharset">CompileToCharSet</a></emu-xref> of <emu-nt id="_ref_24467"><a href="text-processing.html#prod-ClassSetOperand">ClassSetOperand</a></emu-nt> with argument <var>rer</var>.</li><li>If <emu-nt id="_ref_24468"><a href="text-processing.html#prod-ClassUnion">ClassUnion</a></emu-nt> is present, then<ol><li>Let <var>B</var> be <emu-xref aoid="CompileToCharSet" id="_ref_12150"><a href="text-processing.html#sec-compiletocharset">CompileToCharSet</a></emu-xref> of <emu-nt id="_ref_24469"><a href="text-processing.html#prod-ClassUnion">ClassUnion</a></emu-nt> with argument <var>rer</var>.</li><li>Return the union of <emu-xref href="#pattern-charset" id="_ref_12151"><a href="text-processing.html#pattern-charset">CharSets</a></emu-xref> <var>A</var> and <var>B</var>.</li></ol></li><li>Return <var>A</var>.</li></ol></emu-alg>
|
||
|
||
<!-- ClassIntersection -->
|
||
<emu-grammar><emu-production name="ClassIntersection" type="lexical" collapsed="">
|
||
<emu-nt><a href="text-processing.html#prod-ClassIntersection">ClassIntersection</a></emu-nt> <emu-geq>::</emu-geq> <emu-rhs a="ldjtuyxs" id="prod-w2-hkHQn">
|
||
<emu-nt id="_ref_24470"><a href="text-processing.html#prod-ClassSetOperand">ClassSetOperand</a></emu-nt>
|
||
<emu-t>&&</emu-t>
|
||
<emu-nt id="_ref_24471"><a href="text-processing.html#prod-ClassSetOperand">ClassSetOperand</a></emu-nt>
|
||
</emu-rhs>
|
||
</emu-production>
|
||
</emu-grammar>
|
||
<emu-alg><ol><li>Let <var>A</var> be <emu-xref aoid="CompileToCharSet" id="_ref_12152"><a href="text-processing.html#sec-compiletocharset">CompileToCharSet</a></emu-xref> of the first <emu-nt id="_ref_24472"><a href="text-processing.html#prod-ClassSetOperand">ClassSetOperand</a></emu-nt> with argument <var>rer</var>.</li><li>Let <var>B</var> be <emu-xref aoid="CompileToCharSet" id="_ref_12153"><a href="text-processing.html#sec-compiletocharset">CompileToCharSet</a></emu-xref> of the second <emu-nt id="_ref_24473"><a href="text-processing.html#prod-ClassSetOperand">ClassSetOperand</a></emu-nt> with argument <var>rer</var>.</li><li>Return the intersection of <emu-xref href="#pattern-charset" id="_ref_12154"><a href="text-processing.html#pattern-charset">CharSets</a></emu-xref> <var>A</var> and <var>B</var>.</li></ol></emu-alg>
|
||
<emu-grammar><emu-production name="ClassIntersection" type="lexical" collapsed="">
|
||
<emu-nt><a href="text-processing.html#prod-ClassIntersection">ClassIntersection</a></emu-nt> <emu-geq>::</emu-geq> <emu-rhs a="sqaogagb" id="prod--kctPbXq">
|
||
<emu-nt id="_ref_24474"><a href="text-processing.html#prod-ClassIntersection">ClassIntersection</a></emu-nt>
|
||
<emu-t>&&</emu-t>
|
||
<emu-nt id="_ref_24475"><a href="text-processing.html#prod-ClassSetOperand">ClassSetOperand</a></emu-nt>
|
||
</emu-rhs>
|
||
</emu-production>
|
||
</emu-grammar>
|
||
<emu-alg><ol><li>Let <var>A</var> be <emu-xref aoid="CompileToCharSet" id="_ref_12155"><a href="text-processing.html#sec-compiletocharset">CompileToCharSet</a></emu-xref> of the <emu-nt id="_ref_24476"><a href="text-processing.html#prod-ClassIntersection">ClassIntersection</a></emu-nt> with argument <var>rer</var>.</li><li>Let <var>B</var> be <emu-xref aoid="CompileToCharSet" id="_ref_12156"><a href="text-processing.html#sec-compiletocharset">CompileToCharSet</a></emu-xref> of the <emu-nt id="_ref_24477"><a href="text-processing.html#prod-ClassSetOperand">ClassSetOperand</a></emu-nt> with argument <var>rer</var>.</li><li>Return the intersection of <emu-xref href="#pattern-charset" id="_ref_12157"><a href="text-processing.html#pattern-charset">CharSets</a></emu-xref> <var>A</var> and <var>B</var>.</li></ol></emu-alg>
|
||
|
||
<!-- ClassSubtraction -->
|
||
<emu-grammar><emu-production name="ClassSubtraction" type="lexical" collapsed="">
|
||
<emu-nt><a href="text-processing.html#prod-ClassSubtraction">ClassSubtraction</a></emu-nt> <emu-geq>::</emu-geq> <emu-rhs a="0iwjxoz1" id="prod-NbIP4ydn">
|
||
<emu-nt id="_ref_24478"><a href="text-processing.html#prod-ClassSetOperand">ClassSetOperand</a></emu-nt>
|
||
<emu-t>--</emu-t>
|
||
<emu-nt id="_ref_24479"><a href="text-processing.html#prod-ClassSetOperand">ClassSetOperand</a></emu-nt>
|
||
</emu-rhs>
|
||
</emu-production>
|
||
</emu-grammar>
|
||
<emu-alg><ol><li>Let <var>A</var> be <emu-xref aoid="CompileToCharSet" id="_ref_12158"><a href="text-processing.html#sec-compiletocharset">CompileToCharSet</a></emu-xref> of the first <emu-nt id="_ref_24480"><a href="text-processing.html#prod-ClassSetOperand">ClassSetOperand</a></emu-nt> with argument <var>rer</var>.</li><li>Let <var>B</var> be <emu-xref aoid="CompileToCharSet" id="_ref_12159"><a href="text-processing.html#sec-compiletocharset">CompileToCharSet</a></emu-xref> of the second <emu-nt id="_ref_24481"><a href="text-processing.html#prod-ClassSetOperand">ClassSetOperand</a></emu-nt> with argument <var>rer</var>.</li><li>Return the <emu-xref href="#pattern-charset" id="_ref_12160"><a href="text-processing.html#pattern-charset">CharSet</a></emu-xref> containing the CharSetElements of <var>A</var> which are not also CharSetElements of <var>B</var>.</li></ol></emu-alg>
|
||
<emu-grammar><emu-production name="ClassSubtraction" type="lexical" collapsed="">
|
||
<emu-nt><a href="text-processing.html#prod-ClassSubtraction">ClassSubtraction</a></emu-nt> <emu-geq>::</emu-geq> <emu-rhs a="pdtgdxpo" id="prod-rCqAsGUK">
|
||
<emu-nt id="_ref_24482"><a href="text-processing.html#prod-ClassSubtraction">ClassSubtraction</a></emu-nt>
|
||
<emu-t>--</emu-t>
|
||
<emu-nt id="_ref_24483"><a href="text-processing.html#prod-ClassSetOperand">ClassSetOperand</a></emu-nt>
|
||
</emu-rhs>
|
||
</emu-production>
|
||
</emu-grammar>
|
||
<emu-alg><ol><li>Let <var>A</var> be <emu-xref aoid="CompileToCharSet" id="_ref_12161"><a href="text-processing.html#sec-compiletocharset">CompileToCharSet</a></emu-xref> of the <emu-nt id="_ref_24484"><a href="text-processing.html#prod-ClassSubtraction">ClassSubtraction</a></emu-nt> with argument <var>rer</var>.</li><li>Let <var>B</var> be <emu-xref aoid="CompileToCharSet" id="_ref_12162"><a href="text-processing.html#sec-compiletocharset">CompileToCharSet</a></emu-xref> of the <emu-nt id="_ref_24485"><a href="text-processing.html#prod-ClassSetOperand">ClassSetOperand</a></emu-nt> with argument <var>rer</var>.</li><li>Return the <emu-xref href="#pattern-charset" id="_ref_12163"><a href="text-processing.html#pattern-charset">CharSet</a></emu-xref> containing the CharSetElements of <var>A</var> which are not also CharSetElements of <var>B</var>.</li></ol></emu-alg>
|
||
|
||
<!-- ClassSetRange -->
|
||
<emu-grammar><emu-production name="ClassSetRange" type="lexical" collapsed="">
|
||
<emu-nt><a href="text-processing.html#prod-ClassSetRange">ClassSetRange</a></emu-nt> <emu-geq>::</emu-geq> <emu-rhs a="olq8_w1t" id="prod-_hGzIVko">
|
||
<emu-nt id="_ref_24486"><a href="text-processing.html#prod-ClassSetCharacter">ClassSetCharacter</a></emu-nt>
|
||
<emu-t>-</emu-t>
|
||
<emu-nt id="_ref_24487"><a href="text-processing.html#prod-ClassSetCharacter">ClassSetCharacter</a></emu-nt>
|
||
</emu-rhs>
|
||
</emu-production>
|
||
</emu-grammar>
|
||
<emu-alg><ol><li>Let <var>A</var> be <emu-xref aoid="CompileToCharSet" id="_ref_12164"><a href="text-processing.html#sec-compiletocharset">CompileToCharSet</a></emu-xref> of the first <emu-nt id="_ref_24488"><a href="text-processing.html#prod-ClassSetCharacter">ClassSetCharacter</a></emu-nt> with argument <var>rer</var>.</li><li>Let <var>B</var> be <emu-xref aoid="CompileToCharSet" id="_ref_12165"><a href="text-processing.html#sec-compiletocharset">CompileToCharSet</a></emu-xref> of the second <emu-nt id="_ref_24489"><a href="text-processing.html#prod-ClassSetCharacter">ClassSetCharacter</a></emu-nt> with argument <var>rer</var>.</li><li>Return <emu-xref aoid="MaybeSimpleCaseFolding" id="_ref_12166"><a href="text-processing.html#sec-maybesimplecasefolding">MaybeSimpleCaseFolding</a></emu-xref>(<var>rer</var>, <emu-xref aoid="CharacterRange" id="_ref_12167"><a href="text-processing.html#sec-runtime-semantics-characterrange-abstract-operation">CharacterRange</a></emu-xref>(<var>A</var>, <var>B</var>)).</li></ol></emu-alg>
|
||
<emu-note><span class="note">Note 6</span><div class="note-contents">
|
||
<p>The result will often consist of two or more ranges. When UnicodeSets is <emu-val>true</emu-val> and IgnoreCase is <emu-val>true</emu-val>, then <emu-xref aoid="MaybeSimpleCaseFolding" id="_ref_12168"><a href="text-processing.html#sec-maybesimplecasefolding">MaybeSimpleCaseFolding</a></emu-xref>(<var>rer</var>, [Ā-č]) will include only the odd-numbered code points of that range.</p>
|
||
</div></emu-note>
|
||
|
||
<!-- ClassSetOperand -->
|
||
<emu-grammar><emu-production name="ClassSetOperand" type="lexical" collapsed="">
|
||
<emu-nt><a href="text-processing.html#prod-ClassSetOperand">ClassSetOperand</a></emu-nt> <emu-geq>::</emu-geq> <emu-rhs a="pbrz9y58" id="prod-CT-iOKlu"><emu-nt id="_ref_24490"><a href="text-processing.html#prod-ClassSetCharacter">ClassSetCharacter</a></emu-nt></emu-rhs>
|
||
</emu-production>
|
||
</emu-grammar>
|
||
<emu-alg><ol><li>Let <var>A</var> be <emu-xref aoid="CompileToCharSet" id="_ref_12169"><a href="text-processing.html#sec-compiletocharset">CompileToCharSet</a></emu-xref> of <emu-nt id="_ref_24491"><a href="text-processing.html#prod-ClassSetCharacter">ClassSetCharacter</a></emu-nt> with argument <var>rer</var>.</li><li>Return <emu-xref aoid="MaybeSimpleCaseFolding" id="_ref_12170"><a href="text-processing.html#sec-maybesimplecasefolding">MaybeSimpleCaseFolding</a></emu-xref>(<var>rer</var>, <var>A</var>).</li></ol></emu-alg>
|
||
<emu-grammar><emu-production name="ClassSetOperand" type="lexical" collapsed="">
|
||
<emu-nt><a href="text-processing.html#prod-ClassSetOperand">ClassSetOperand</a></emu-nt> <emu-geq>::</emu-geq> <emu-rhs a="gmk8rsml" id="prod-Dc11md8Q"><emu-nt id="_ref_24492"><a href="text-processing.html#prod-ClassStringDisjunction">ClassStringDisjunction</a></emu-nt></emu-rhs>
|
||
</emu-production>
|
||
</emu-grammar>
|
||
<emu-alg><ol><li>Let <var>A</var> be <emu-xref aoid="CompileToCharSet" id="_ref_12171"><a href="text-processing.html#sec-compiletocharset">CompileToCharSet</a></emu-xref> of <emu-nt id="_ref_24493"><a href="text-processing.html#prod-ClassStringDisjunction">ClassStringDisjunction</a></emu-nt> with argument <var>rer</var>.</li><li>Return <emu-xref aoid="MaybeSimpleCaseFolding" id="_ref_12172"><a href="text-processing.html#sec-maybesimplecasefolding">MaybeSimpleCaseFolding</a></emu-xref>(<var>rer</var>, <var>A</var>).</li></ol></emu-alg>
|
||
<emu-grammar><emu-production name="ClassSetOperand" type="lexical" collapsed="">
|
||
<emu-nt><a href="text-processing.html#prod-ClassSetOperand">ClassSetOperand</a></emu-nt> <emu-geq>::</emu-geq> <emu-rhs a="bz00qqkp" id="prod-uLxuDcXH"><emu-nt id="_ref_24494"><a href="text-processing.html#prod-NestedClass">NestedClass</a></emu-nt></emu-rhs>
|
||
</emu-production>
|
||
</emu-grammar>
|
||
<emu-alg><ol><li>Return <emu-xref aoid="CompileToCharSet" id="_ref_12173"><a href="text-processing.html#sec-compiletocharset">CompileToCharSet</a></emu-xref> of <emu-nt id="_ref_24495"><a href="text-processing.html#prod-NestedClass">NestedClass</a></emu-nt> with argument <var>rer</var>.</li></ol></emu-alg>
|
||
|
||
<!-- NestedClass -->
|
||
<emu-grammar><emu-production name="NestedClass" type="lexical" collapsed="">
|
||
<emu-nt><a href="text-processing.html#prod-NestedClass">NestedClass</a></emu-nt> <emu-geq>::</emu-geq> <emu-rhs a="i-ml-nlt" id="prod-o6xG9Ln_">
|
||
<emu-t>[</emu-t>
|
||
<emu-nt id="_ref_24496"><a href="text-processing.html#prod-ClassContents">ClassContents</a></emu-nt>
|
||
<emu-t>]</emu-t>
|
||
</emu-rhs>
|
||
</emu-production>
|
||
</emu-grammar>
|
||
<emu-alg><ol><li>Return <emu-xref aoid="CompileToCharSet" id="_ref_12174"><a href="text-processing.html#sec-compiletocharset">CompileToCharSet</a></emu-xref> of <emu-nt id="_ref_24497"><a href="text-processing.html#prod-ClassContents">ClassContents</a></emu-nt> with argument <var>rer</var>.</li></ol></emu-alg>
|
||
<emu-grammar><emu-production name="NestedClass" type="lexical" collapsed="">
|
||
<emu-nt><a href="text-processing.html#prod-NestedClass">NestedClass</a></emu-nt> <emu-geq>::</emu-geq> <emu-rhs a="d-swr39f" id="prod-FNPscJtz">
|
||
<emu-t>[^</emu-t>
|
||
<emu-nt id="_ref_24498"><a href="text-processing.html#prod-ClassContents">ClassContents</a></emu-nt>
|
||
<emu-t>]</emu-t>
|
||
</emu-rhs>
|
||
</emu-production>
|
||
</emu-grammar>
|
||
<emu-alg><ol><li>Let <var>A</var> be <emu-xref aoid="CompileToCharSet" id="_ref_12175"><a href="text-processing.html#sec-compiletocharset">CompileToCharSet</a></emu-xref> of <emu-nt id="_ref_24499"><a href="text-processing.html#prod-ClassContents">ClassContents</a></emu-nt> with argument <var>rer</var>.</li><li>Return <emu-xref aoid="CharacterComplement" id="_ref_12176"><a href="text-processing.html#sec-charactercomplement">CharacterComplement</a></emu-xref>(<var>rer</var>, <var>A</var>).</li></ol></emu-alg>
|
||
<emu-grammar><emu-production name="NestedClass" type="lexical" collapsed="">
|
||
<emu-nt><a href="text-processing.html#prod-NestedClass">NestedClass</a></emu-nt> <emu-geq>::</emu-geq> <emu-rhs a="fmrtucj_" id="prod-qeN2oG49">
|
||
<emu-t>\</emu-t>
|
||
<emu-nt id="_ref_24500"><a href="text-processing.html#prod-CharacterClassEscape">CharacterClassEscape</a></emu-nt>
|
||
</emu-rhs>
|
||
</emu-production>
|
||
</emu-grammar>
|
||
<emu-alg><ol><li>Return <emu-xref aoid="CompileToCharSet" id="_ref_12177"><a href="text-processing.html#sec-compiletocharset">CompileToCharSet</a></emu-xref> of <emu-nt id="_ref_24501"><a href="text-processing.html#prod-CharacterClassEscape">CharacterClassEscape</a></emu-nt> with argument <var>rer</var>.</li></ol></emu-alg>
|
||
|
||
<!-- ClassStringDisjunction -->
|
||
<emu-grammar><emu-production name="ClassStringDisjunction" type="lexical" collapsed="">
|
||
<emu-nt><a href="text-processing.html#prod-ClassStringDisjunction">ClassStringDisjunction</a></emu-nt> <emu-geq>::</emu-geq> <emu-rhs a="kjbhn6ad" id="prod-D8tzzCjX">
|
||
<emu-t>\q{</emu-t>
|
||
<emu-nt id="_ref_24502"><a href="text-processing.html#prod-ClassStringDisjunctionContents">ClassStringDisjunctionContents</a></emu-nt>
|
||
<emu-t>}</emu-t>
|
||
</emu-rhs>
|
||
</emu-production>
|
||
</emu-grammar>
|
||
<emu-alg><ol><li>Return <emu-xref aoid="CompileToCharSet" id="_ref_12178"><a href="text-processing.html#sec-compiletocharset">CompileToCharSet</a></emu-xref> of <emu-nt id="_ref_24503"><a href="text-processing.html#prod-ClassStringDisjunctionContents">ClassStringDisjunctionContents</a></emu-nt> with argument <var>rer</var>.</li></ol></emu-alg>
|
||
|
||
<!-- ClassStringDisjunctionContents -->
|
||
<emu-grammar><emu-production name="ClassStringDisjunctionContents" type="lexical" collapsed="">
|
||
<emu-nt><a href="text-processing.html#prod-ClassStringDisjunctionContents">ClassStringDisjunctionContents</a></emu-nt> <emu-geq>::</emu-geq> <emu-rhs a="-skvesn5" id="prod-S1fk5A6Q"><emu-nt id="_ref_24504"><a href="text-processing.html#prod-ClassString">ClassString</a></emu-nt></emu-rhs>
|
||
</emu-production>
|
||
</emu-grammar>
|
||
<emu-alg><ol><li>Let <var>s</var> be <emu-xref aoid="CompileClassSetString" id="_ref_12179"><a href="text-processing.html#sec-compileclasssetstring">CompileClassSetString</a></emu-xref> of <emu-nt id="_ref_24505"><a href="text-processing.html#prod-ClassString">ClassString</a></emu-nt> with argument <var>rer</var>.</li><li>Return the <emu-xref href="#pattern-charset" id="_ref_12180"><a href="text-processing.html#pattern-charset">CharSet</a></emu-xref> containing the one string <var>s</var>.</li></ol></emu-alg>
|
||
<emu-grammar><emu-production name="ClassStringDisjunctionContents" type="lexical" collapsed="">
|
||
<emu-nt><a href="text-processing.html#prod-ClassStringDisjunctionContents">ClassStringDisjunctionContents</a></emu-nt> <emu-geq>::</emu-geq> <emu-rhs a="bsmwgovm" id="prod-r5_vzTE6">
|
||
<emu-nt id="_ref_24506"><a href="text-processing.html#prod-ClassString">ClassString</a></emu-nt>
|
||
<emu-t>|</emu-t>
|
||
<emu-nt id="_ref_24507"><a href="text-processing.html#prod-ClassStringDisjunctionContents">ClassStringDisjunctionContents</a></emu-nt>
|
||
</emu-rhs>
|
||
</emu-production>
|
||
</emu-grammar>
|
||
<emu-alg><ol><li>Let <var>s</var> be <emu-xref aoid="CompileClassSetString" id="_ref_12181"><a href="text-processing.html#sec-compileclasssetstring">CompileClassSetString</a></emu-xref> of <emu-nt id="_ref_24508"><a href="text-processing.html#prod-ClassString">ClassString</a></emu-nt> with argument <var>rer</var>.</li><li>Let <var>A</var> be the <emu-xref href="#pattern-charset" id="_ref_12182"><a href="text-processing.html#pattern-charset">CharSet</a></emu-xref> containing the one string <var>s</var>.</li><li>Let <var>B</var> be <emu-xref aoid="CompileToCharSet" id="_ref_12183"><a href="text-processing.html#sec-compiletocharset">CompileToCharSet</a></emu-xref> of <emu-nt id="_ref_24509"><a href="text-processing.html#prod-ClassStringDisjunctionContents">ClassStringDisjunctionContents</a></emu-nt> with argument <var>rer</var>.</li><li>Return the union of <emu-xref href="#pattern-charset" id="_ref_12184"><a href="text-processing.html#pattern-charset">CharSets</a></emu-xref> <var>A</var> and <var>B</var>.</li></ol></emu-alg>
|
||
|
||
<!-- ClassSetCharacter -->
|
||
<emu-grammar><emu-production name="ClassSetCharacter" type="lexical">
|
||
<emu-nt><a href="text-processing.html#prod-ClassSetCharacter">ClassSetCharacter</a></emu-nt> <emu-geq>::</emu-geq> <emu-rhs a="kyrub20l" id="prod-VEApxZ79">
|
||
<emu-nt id="_ref_24510"><a href="ecmascript-language-source-code.html#prod-SourceCharacter">SourceCharacter</a></emu-nt> <emu-gmod>but not <emu-nt id="_ref_24511"><a href="text-processing.html#prod-ClassSetSyntaxCharacter">ClassSetSyntaxCharacter</a></emu-nt></emu-gmod>
|
||
</emu-rhs>
|
||
<emu-rhs a="ihzyy-yc" id="prod-opgR2DMh">
|
||
<emu-t>\</emu-t>
|
||
<emu-nt id="_ref_24512"><a href="text-processing.html#prod-CharacterEscape">CharacterEscape</a></emu-nt>
|
||
</emu-rhs>
|
||
<emu-rhs a="xyoixwqd" id="prod-yQoZkx34">
|
||
<emu-t>\</emu-t>
|
||
<emu-nt id="_ref_24513"><a href="text-processing.html#prod-ClassSetReservedPunctuator">ClassSetReservedPunctuator</a></emu-nt>
|
||
</emu-rhs>
|
||
</emu-production>
|
||
</emu-grammar>
|
||
<emu-alg><ol><li>Let <var>cv</var> be the <emu-xref aoid="CharacterValue" id="_ref_12185"><a href="text-processing.html#sec-patterns-static-semantics-character-value">CharacterValue</a></emu-xref> of this <emu-nt id="_ref_24514"><a href="text-processing.html#prod-ClassSetCharacter">ClassSetCharacter</a></emu-nt>.</li><li>Let <var>c</var> be the character whose character value is <var>cv</var>.</li><li>Return the <emu-xref href="#pattern-charset" id="_ref_12186"><a href="text-processing.html#pattern-charset">CharSet</a></emu-xref> containing the single character <var>c</var>.</li></ol></emu-alg>
|
||
<emu-grammar><emu-production name="ClassSetCharacter" type="lexical" collapsed="">
|
||
<emu-nt><a href="text-processing.html#prod-ClassSetCharacter">ClassSetCharacter</a></emu-nt> <emu-geq>::</emu-geq> <emu-rhs a="axxsqknu" id="prod-lqd7zk2t"><emu-t>\b</emu-t></emu-rhs>
|
||
</emu-production>
|
||
</emu-grammar>
|
||
<emu-alg><ol><li>Return the <emu-xref href="#pattern-charset" id="_ref_12187"><a href="text-processing.html#pattern-charset">CharSet</a></emu-xref> containing the single character U+0008 (BACKSPACE).</li></ol></emu-alg>
|
||
|
||
<emu-clause id="sec-runtime-semantics-characterrange-abstract-operation" type="abstract operation" aoid="CharacterRange">
|
||
<h1><span class="secnum">22.2.2.9.1</span> CharacterRange ( <var>A</var>, <var>B</var> )</h1>
|
||
<p>The abstract operation CharacterRange takes arguments <var>A</var> (a <emu-xref href="#pattern-charset" id="_ref_12188"><a href="text-processing.html#pattern-charset">CharSet</a></emu-xref>) and <var>B</var> (a <emu-xref href="#pattern-charset" id="_ref_12189"><a href="text-processing.html#pattern-charset">CharSet</a></emu-xref>) and returns a <emu-xref href="#pattern-charset" id="_ref_12190"><a href="text-processing.html#pattern-charset">CharSet</a></emu-xref>. It performs the following steps when called:</p>
|
||
<emu-alg><ol><li><emu-xref href="#assert" id="_ref_12191"><a href="notational-conventions.html#assert">Assert</a></emu-xref>: <var>A</var> and <var>B</var> each contain exactly one character.</li><li>Let <var>a</var> be the one character in <emu-xref href="#pattern-charset" id="_ref_12192"><a href="text-processing.html#pattern-charset">CharSet</a></emu-xref> <var>A</var>.</li><li>Let <var>b</var> be the one character in <emu-xref href="#pattern-charset" id="_ref_12193"><a href="text-processing.html#pattern-charset">CharSet</a></emu-xref> <var>B</var>.</li><li>Let <var>i</var> be the character value of character <var>a</var>.</li><li>Let <var>j</var> be the character value of character <var>b</var>.</li><li><emu-xref href="#assert" id="_ref_12194"><a href="notational-conventions.html#assert">Assert</a></emu-xref>: <var>i</var> ≤ <var>j</var>.</li><li>Return the <emu-xref href="#pattern-charset" id="_ref_12195"><a href="text-processing.html#pattern-charset">CharSet</a></emu-xref> containing all characters with a character value in the <emu-xref href="#inclusive-interval" id="_ref_12196"><a href="notational-conventions.html#inclusive-interval">inclusive interval</a></emu-xref> from <var>i</var> to <var>j</var>.</li></ol></emu-alg>
|
||
</emu-clause>
|
||
|
||
<emu-clause id="sec-runtime-semantics-haseitherunicodeflag-abstract-operation" type="abstract operation" aoid="HasEitherUnicodeFlag">
|
||
<h1><span class="secnum">22.2.2.9.2</span> HasEitherUnicodeFlag ( <var>rer</var> )</h1>
|
||
<p>The abstract operation HasEitherUnicodeFlag takes argument <var>rer</var> (a <emu-xref href="#sec-regexp-records" id="_ref_12197"><a href="text-processing.html#sec-regexp-records">RegExp Record</a></emu-xref>) and returns a Boolean. It performs the following steps when called:</p>
|
||
<emu-alg><ol><li>If <var>rer</var>.<var class="field">[[Unicode]]</var> is <emu-val>true</emu-val> or <var>rer</var>.<var class="field">[[UnicodeSets]]</var> is <emu-val>true</emu-val>, return <emu-val>true</emu-val>.</li><li>Return <emu-val>false</emu-val>.</li></ol></emu-alg>
|
||
</emu-clause>
|
||
|
||
<emu-clause id="sec-wordcharacters" type="abstract operation" oldids="sec-runtime-semantics-wordcharacters-abstract-operation" aoid="WordCharacters"><span id="sec-runtime-semantics-wordcharacters-abstract-operation"></span>
|
||
<h1><span class="secnum">22.2.2.9.3</span> WordCharacters ( <var>rer</var> )</h1>
|
||
<p>The abstract operation WordCharacters takes argument <var>rer</var> (a <emu-xref href="#sec-regexp-records" id="_ref_12198"><a href="text-processing.html#sec-regexp-records">RegExp Record</a></emu-xref>) and returns a <emu-xref href="#pattern-charset" id="_ref_12199"><a href="text-processing.html#pattern-charset">CharSet</a></emu-xref>. Returns a <emu-xref href="#pattern-charset" id="_ref_12200"><a href="text-processing.html#pattern-charset">CharSet</a></emu-xref> containing the characters considered "word characters" for the purposes of <code>\b</code>, <code>\B</code>, <code>\w</code>, and <code>\W</code> It performs the following steps when called:</p>
|
||
<emu-alg><ol><li>Let <var>basicWordChars</var> be the <emu-xref href="#pattern-charset" id="_ref_12201"><a href="text-processing.html#pattern-charset">CharSet</a></emu-xref> containing every character in <emu-xref href="#ASCII-word-characters" id="_ref_12202"><a href="ecmascript-data-types-and-values.html#ASCII-word-characters">the ASCII word characters</a></emu-xref>.</li><li>Let <var>extraWordChars</var> be the <emu-xref href="#pattern-charset" id="_ref_12203"><a href="text-processing.html#pattern-charset">CharSet</a></emu-xref> containing all characters <var>c</var> such that <var>c</var> is not in <var>basicWordChars</var> but <emu-xref aoid="Canonicalize" id="_ref_12204"><a href="text-processing.html#sec-runtime-semantics-canonicalize-ch">Canonicalize</a></emu-xref>(<var>rer</var>, <var>c</var>) is in <var>basicWordChars</var>.</li><li><emu-xref href="#assert" id="_ref_12205"><a href="notational-conventions.html#assert">Assert</a></emu-xref>: <var>extraWordChars</var> is empty unless <emu-xref aoid="HasEitherUnicodeFlag" id="_ref_12206"><a href="text-processing.html#sec-runtime-semantics-haseitherunicodeflag-abstract-operation">HasEitherUnicodeFlag</a></emu-xref>(<var>rer</var>) is <emu-val>true</emu-val> and <var>rer</var>.<var class="field">[[IgnoreCase]]</var> is <emu-val>true</emu-val>.</li><li>Return the union of <var>basicWordChars</var> and <var>extraWordChars</var>.</li></ol></emu-alg>
|
||
</emu-clause>
|
||
|
||
<emu-clause id="sec-allcharacters" type="abstract operation" aoid="AllCharacters">
|
||
<h1><span class="secnum">22.2.2.9.4</span> AllCharacters ( <var>rer</var> )</h1>
|
||
<p>The abstract operation AllCharacters takes argument <var>rer</var> (a <emu-xref href="#sec-regexp-records" id="_ref_12207"><a href="text-processing.html#sec-regexp-records">RegExp Record</a></emu-xref>) and returns a <emu-xref href="#pattern-charset" id="_ref_12208"><a href="text-processing.html#pattern-charset">CharSet</a></emu-xref>. Returns the set of “all characters” according to the regular expression flags. It performs the following steps when called:</p>
|
||
<emu-alg><ol><li>If <var>rer</var>.<var class="field">[[UnicodeSets]]</var> is <emu-val>true</emu-val> and <var>rer</var>.<var class="field">[[IgnoreCase]]</var> is <emu-val>true</emu-val>, then<ol><li declared="c">Return the <emu-xref href="#pattern-charset" id="_ref_12209"><a href="text-processing.html#pattern-charset">CharSet</a></emu-xref> containing all Unicode code points <var>c</var> that do not have a <a href="https://www.unicode.org/reports/tr44/#Simple_Case_Folding">Simple Case Folding</a> mapping (that is, <emu-xref aoid="scf" id="_ref_12210"><a href="text-processing.html#eqn-scf">scf</a></emu-xref>(<var>c</var>)=<var>c</var>).</li></ol></li><li>If <emu-xref aoid="HasEitherUnicodeFlag" id="_ref_12211"><a href="text-processing.html#sec-runtime-semantics-haseitherunicodeflag-abstract-operation">HasEitherUnicodeFlag</a></emu-xref>(<var>rer</var>) is <emu-val>true</emu-val>, then<ol><li>Return the <emu-xref href="#pattern-charset" id="_ref_12212"><a href="text-processing.html#pattern-charset">CharSet</a></emu-xref> containing all code point values.</li></ol></li><li>Return the <emu-xref href="#pattern-charset" id="_ref_12213"><a href="text-processing.html#pattern-charset">CharSet</a></emu-xref> containing all code unit values.</li></ol></emu-alg>
|
||
</emu-clause>
|
||
|
||
<emu-clause id="sec-maybesimplecasefolding" type="abstract operation" aoid="MaybeSimpleCaseFolding">
|
||
<h1><span class="secnum">22.2.2.9.5</span> MaybeSimpleCaseFolding ( <var>rer</var>, <var>A</var> )</h1>
|
||
<p>The abstract operation MaybeSimpleCaseFolding takes arguments <var>rer</var> (a <emu-xref href="#sec-regexp-records" id="_ref_12214"><a href="text-processing.html#sec-regexp-records">RegExp Record</a></emu-xref>) and <var>A</var> (a <emu-xref href="#pattern-charset" id="_ref_12215"><a href="text-processing.html#pattern-charset">CharSet</a></emu-xref>) and returns a <emu-xref href="#pattern-charset" id="_ref_12216"><a href="text-processing.html#pattern-charset">CharSet</a></emu-xref>. If <var>rer</var>.<var class="field">[[UnicodeSets]]</var> is <emu-val>false</emu-val> or <var>rer</var>.<var class="field">[[IgnoreCase]]</var> is <emu-val>false</emu-val>, it returns <var>A</var>. Otherwise, it uses the <a href="https://www.unicode.org/reports/tr44/#Simple_Case_Folding">Simple Case Folding</a> (<emu-eqn id="eqn-scf" aoid="scf" class="inline">scf(<var>cp</var>)</emu-eqn>) definitions in the file <a href="https://unicode.org/Public/UCD/latest/ucd/CaseFolding.txt"><code>CaseFolding.txt</code></a> of the Unicode Character Database (each of which maps a single code point to another single code point) to map each <emu-xref href="#sec-pattern-notation" id="_ref_12217"><a href="text-processing.html#sec-pattern-notation">CharSetElement</a></emu-xref> of <var>A</var> character-by-character into a canonical form and returns the resulting <emu-xref href="#pattern-charset" id="_ref_12218"><a href="text-processing.html#pattern-charset">CharSet</a></emu-xref>. It performs the following steps when called:</p>
|
||
<emu-alg><ol><li>If <var>rer</var>.<var class="field">[[UnicodeSets]]</var> is <emu-val>false</emu-val> or <var>rer</var>.<var class="field">[[IgnoreCase]]</var> is <emu-val>false</emu-val>, return <var>A</var>.</li><li>Let <var>B</var> be a new empty <emu-xref href="#pattern-charset" id="_ref_12219"><a href="text-processing.html#pattern-charset">CharSet</a></emu-xref>.</li><li>For each <emu-xref href="#sec-pattern-notation" id="_ref_12220"><a href="text-processing.html#sec-pattern-notation">CharSetElement</a></emu-xref> <var>s</var> of <var>A</var>, do<ol><li>Let <var>t</var> be an empty sequence of characters.</li><li>For each single code point <var>cp</var> in <var>s</var>, do<ol><li>Append <emu-xref aoid="scf" id="_ref_12221"><a href="text-processing.html#eqn-scf">scf</a></emu-xref>(<var>cp</var>) to <var>t</var>.</li></ol></li><li>Add <var>t</var> to <var>B</var>.</li></ol></li><li>Return <var>B</var>.</li></ol></emu-alg>
|
||
</emu-clause>
|
||
|
||
<emu-clause id="sec-charactercomplement" type="abstract operation" aoid="CharacterComplement">
|
||
<h1><span class="secnum">22.2.2.9.6</span> CharacterComplement ( <var>rer</var>, <var>S</var> )</h1>
|
||
<p>The abstract operation CharacterComplement takes arguments <var>rer</var> (a <emu-xref href="#sec-regexp-records" id="_ref_12222"><a href="text-processing.html#sec-regexp-records">RegExp Record</a></emu-xref>) and <var>S</var> (a <emu-xref href="#pattern-charset" id="_ref_12223"><a href="text-processing.html#pattern-charset">CharSet</a></emu-xref>) and returns a <emu-xref href="#pattern-charset" id="_ref_12224"><a href="text-processing.html#pattern-charset">CharSet</a></emu-xref>. It performs the following steps when called:</p>
|
||
<emu-alg><ol><li>Let <var>A</var> be <emu-xref aoid="AllCharacters" id="_ref_12225"><a href="text-processing.html#sec-allcharacters">AllCharacters</a></emu-xref>(<var>rer</var>).</li><li>Return the <emu-xref href="#pattern-charset" id="_ref_12226"><a href="text-processing.html#pattern-charset">CharSet</a></emu-xref> containing the CharSetElements of <var>A</var> which are not also CharSetElements of <var>S</var>.</li></ol></emu-alg>
|
||
</emu-clause>
|
||
|
||
<emu-clause id="sec-runtime-semantics-unicodematchproperty-p" type="abstract operation" aoid="UnicodeMatchProperty">
|
||
<h1><span class="secnum">22.2.2.9.7</span> UnicodeMatchProperty ( <var>rer</var>, <var>p</var> )</h1>
|
||
<p>The abstract operation UnicodeMatchProperty takes arguments <var>rer</var> (a <emu-xref href="#sec-regexp-records" id="_ref_12227"><a href="text-processing.html#sec-regexp-records">RegExp Record</a></emu-xref>) and <var>p</var> (<emu-xref href="#sec-source-text" id="_ref_12228"><a href="ecmascript-language-source-code.html#sec-source-text">ECMAScript source text</a></emu-xref>) and returns a <emu-not-ref>Unicode property name</emu-not-ref>. It performs the following steps when called:</p>
|
||
<emu-alg><ol><li>If <var>rer</var>.<var class="field">[[UnicodeSets]]</var> is <emu-val>true</emu-val> and <var>p</var> is a <emu-not-ref>Unicode property name</emu-not-ref> listed in the “<emu-not-ref>Property name</emu-not-ref>” column of <emu-xref href="#table-binary-unicode-properties-of-strings" id="_ref_700"><a href="text-processing.html#table-binary-unicode-properties-of-strings">Table 66</a></emu-xref>, then<ol><li>Return the <emu-xref href="#sec-list-and-record-specification-type" id="_ref_12229"><a href="ecmascript-data-types-and-values.html#sec-list-and-record-specification-type">List</a></emu-xref> of Unicode code points <var>p</var>.</li></ol></li><li><emu-xref href="#assert" id="_ref_12230"><a href="notational-conventions.html#assert">Assert</a></emu-xref>: <var>p</var> is a <emu-not-ref>Unicode property name</emu-not-ref> or property alias listed in the “<emu-not-ref>Property name and aliases</emu-not-ref>” column of <emu-xref href="#table-nonbinary-unicode-properties" id="_ref_701"><a href="text-processing.html#table-nonbinary-unicode-properties">Table 64</a></emu-xref> or <emu-xref href="#table-binary-unicode-properties" id="_ref_702"><a href="text-processing.html#table-binary-unicode-properties">Table 65</a></emu-xref>.</li><li>Let <var>c</var> be the canonical <emu-not-ref>property name</emu-not-ref> of <var>p</var> as given in the “<emu-not-ref>Canonical property name</emu-not-ref>” column of the corresponding row.</li><li>Return the <emu-xref href="#sec-list-and-record-specification-type" id="_ref_12231"><a href="ecmascript-data-types-and-values.html#sec-list-and-record-specification-type">List</a></emu-xref> of Unicode code points <var>c</var>.</li></ol></emu-alg>
|
||
<p>Implementations must support the <emu-not-ref>Unicode property names</emu-not-ref> and aliases listed in <emu-xref href="#table-nonbinary-unicode-properties" id="_ref_703"><a href="text-processing.html#table-nonbinary-unicode-properties">Table 64</a></emu-xref>, <emu-xref href="#table-binary-unicode-properties" id="_ref_704"><a href="text-processing.html#table-binary-unicode-properties">Table 65</a></emu-xref>, and <emu-xref href="#table-binary-unicode-properties-of-strings" id="_ref_705"><a href="text-processing.html#table-binary-unicode-properties-of-strings">Table 66</a></emu-xref>. To ensure interoperability, implementations must not support any other <emu-not-ref>property names</emu-not-ref> or aliases.</p>
|
||
<emu-note><span class="note">Note 1</span><div class="note-contents">
|
||
<p>For example, <code>Script_Extensions</code> (<emu-not-ref>property name</emu-not-ref>) and <code>scx</code> (property alias) are valid, but <code>script_extensions</code> or <code>Scx</code> aren't.</p>
|
||
</div></emu-note>
|
||
<emu-note><span class="note">Note 2</span><div class="note-contents">
|
||
<p>The listed properties form a superset of what <a href="https://unicode.org/reports/tr18/#RL1.2">UTS18 RL1.2</a> requires.</p>
|
||
</div></emu-note>
|
||
<emu-note><span class="note">Note 3</span><div class="note-contents">
|
||
<p>The spellings of entries in these tables (including casing) match the spellings used in the file <a href="https://unicode.org/Public/UCD/latest/ucd/PropertyAliases.txt"><code>PropertyAliases.txt</code></a> in the Unicode Character Database. The precise spellings in that file are <a href="https://www.unicode.org/policies/stability_policy.html#Alias_Stability">guaranteed to be stable</a>.</p>
|
||
</div></emu-note>
|
||
<emu-table id="table-nonbinary-unicode-properties"><figure><figcaption>Table 64: Non-binary Unicode property aliases and their canonical <emu-not-ref>property names</emu-not-ref></figcaption>
|
||
|
||
<table class="real-table unicode-property-table">
|
||
<thead>
|
||
<tr>
|
||
<th><emu-not-ref>Property name and aliases</emu-not-ref></th>
|
||
<th><emu-not-ref>Canonical property name</emu-not-ref></th>
|
||
</tr>
|
||
</thead>
|
||
<tbody><tr>
|
||
<td><code>General_Category</code></td>
|
||
<td rowspan="2"><a href="https://unicode.org/reports/tr18/#General_Category_Property"><code>General_Category</code></a></td>
|
||
</tr>
|
||
<tr>
|
||
<td><code>gc</code></td>
|
||
</tr>
|
||
<tr>
|
||
<td><code>Script</code></td>
|
||
<td rowspan="2"><a href="https://unicode.org/reports/tr24/#Script"><code>Script</code></a></td>
|
||
</tr>
|
||
<tr>
|
||
<td><code>sc</code></td>
|
||
</tr>
|
||
<tr>
|
||
<td><code>Script_Extensions</code></td>
|
||
<td rowspan="2"><a href="https://unicode.org/reports/tr24/#Script_Extensions"><code>Script_Extensions</code></a></td>
|
||
</tr>
|
||
<tr>
|
||
<td><code>scx</code></td>
|
||
</tr>
|
||
</tbody></table>
|
||
</figure></emu-table>
|
||
|
||
<emu-table id="table-binary-unicode-properties"><figure><figcaption>Table 65: Binary Unicode property aliases and their canonical <emu-not-ref>property names</emu-not-ref></figcaption>
|
||
|
||
<table class="real-table unicode-property-table">
|
||
<thead>
|
||
<tr>
|
||
<th><emu-not-ref>Property name and aliases</emu-not-ref></th>
|
||
<th><emu-not-ref>Canonical property name</emu-not-ref></th>
|
||
</tr>
|
||
</thead>
|
||
<tbody><tr>
|
||
<td><code>ASCII</code></td>
|
||
<td><a href="https://unicode.org/reports/tr18/#General_Category_Property"><code>ASCII</code></a></td>
|
||
</tr>
|
||
<tr>
|
||
<td><code>ASCII_Hex_Digit</code></td>
|
||
<td rowspan="2"><a href="https://unicode.org/reports/tr44/#ASCII_Hex_Digit"><code>ASCII_Hex_Digit</code></a></td>
|
||
</tr>
|
||
<tr>
|
||
<td><code>AHex</code></td>
|
||
</tr>
|
||
<tr>
|
||
<td><code>Alphabetic</code></td>
|
||
<td rowspan="2"><a href="https://unicode.org/reports/tr44/#Alphabetic"><code>Alphabetic</code></a></td>
|
||
</tr>
|
||
<tr>
|
||
<td><code>Alpha</code></td>
|
||
</tr>
|
||
<tr>
|
||
<td><code>Any</code></td>
|
||
<td><a href="https://unicode.org/reports/tr18/#General_Category_Property"><code>Any</code></a></td>
|
||
</tr>
|
||
<tr>
|
||
<td><code>Assigned</code></td>
|
||
<td><a href="https://unicode.org/reports/tr18/#General_Category_Property"><code>Assigned</code></a></td>
|
||
</tr>
|
||
<tr>
|
||
<td><code>Bidi_Control</code></td>
|
||
<td rowspan="2"><a href="https://unicode.org/reports/tr44/#Bidi_Control"><code>Bidi_Control</code></a></td>
|
||
</tr>
|
||
<tr>
|
||
<td><code>Bidi_C</code></td>
|
||
</tr>
|
||
<tr>
|
||
<td><code>Bidi_Mirrored</code></td>
|
||
<td rowspan="2"><a href="https://unicode.org/reports/tr44/#Bidi_Mirrored"><code>Bidi_Mirrored</code></a></td>
|
||
</tr>
|
||
<tr>
|
||
<td><code>Bidi_M</code></td>
|
||
</tr>
|
||
<tr>
|
||
<td><code>Case_Ignorable</code></td>
|
||
<td rowspan="2"><a href="https://unicode.org/reports/tr44/#Case_Ignorable"><code>Case_Ignorable</code></a></td>
|
||
</tr>
|
||
<tr>
|
||
<td><code>CI</code></td>
|
||
</tr>
|
||
<tr>
|
||
<td><code>Cased</code></td>
|
||
<td><a href="https://unicode.org/reports/tr44/#Cased"><code>Cased</code></a></td>
|
||
</tr>
|
||
<tr>
|
||
<td><code>Changes_When_Casefolded</code></td>
|
||
<td rowspan="2"><a href="https://unicode.org/reports/tr44/#CWCF"><code>Changes_When_Casefolded</code></a></td>
|
||
</tr>
|
||
<tr>
|
||
<td><code>CWCF</code></td>
|
||
</tr>
|
||
<tr>
|
||
<td><code>Changes_When_Casemapped</code></td>
|
||
<td rowspan="2"><a href="https://unicode.org/reports/tr44/#CWCM"><code>Changes_When_Casemapped</code></a></td>
|
||
</tr>
|
||
<tr>
|
||
<td><code>CWCM</code></td>
|
||
</tr>
|
||
<tr>
|
||
<td><code>Changes_When_Lowercased</code></td>
|
||
<td rowspan="2"><a href="https://unicode.org/reports/tr44/#CWL"><code>Changes_When_Lowercased</code></a></td>
|
||
</tr>
|
||
<tr>
|
||
<td><code>CWL</code></td>
|
||
</tr>
|
||
<tr>
|
||
<td><code>Changes_When_NFKC_Casefolded</code></td>
|
||
<td rowspan="2"><a href="https://unicode.org/reports/tr44/#CWKCF"><code>Changes_When_NFKC_Casefolded</code></a></td>
|
||
</tr>
|
||
<tr>
|
||
<td><code>CWKCF</code></td>
|
||
</tr>
|
||
<tr>
|
||
<td><code>Changes_When_Titlecased</code></td>
|
||
<td rowspan="2"><a href="https://unicode.org/reports/tr44/#CWT"><code>Changes_When_Titlecased</code></a></td>
|
||
</tr>
|
||
<tr>
|
||
<td><code>CWT</code></td>
|
||
</tr>
|
||
<tr>
|
||
<td><code>Changes_When_Uppercased</code></td>
|
||
<td rowspan="2"><a href="https://unicode.org/reports/tr44/#CWU"><code>Changes_When_Uppercased</code></a></td>
|
||
</tr>
|
||
<tr>
|
||
<td><code>CWU</code></td>
|
||
</tr>
|
||
<tr>
|
||
<td><code>Dash</code></td>
|
||
<td><a href="https://unicode.org/reports/tr44/#Dash"><code>Dash</code></a></td>
|
||
</tr>
|
||
<tr>
|
||
<td><code>Default_Ignorable_Code_Point</code></td>
|
||
<td rowspan="2"><a href="https://unicode.org/reports/tr44/#Default_Ignorable_Code_Point"><code>Default_Ignorable_Code_Point</code></a></td>
|
||
</tr>
|
||
<tr>
|
||
<td><code>DI</code></td>
|
||
</tr>
|
||
<tr>
|
||
<td><code>Deprecated</code></td>
|
||
<td rowspan="2"><a href="https://unicode.org/reports/tr44/#Deprecated"><code>Deprecated</code></a></td>
|
||
</tr>
|
||
<tr>
|
||
<td><code>Dep</code></td>
|
||
</tr>
|
||
<tr>
|
||
<td><code>Diacritic</code></td>
|
||
<td rowspan="2"><a href="https://unicode.org/reports/tr44/#Diacritic"><code>Diacritic</code></a></td>
|
||
</tr>
|
||
<tr>
|
||
<td><code>Dia</code></td>
|
||
</tr>
|
||
<tr>
|
||
<td><code>Emoji</code></td>
|
||
<td><a href="https://unicode.org/reports/tr51/#Emoji_Properties"><code>Emoji</code></a></td>
|
||
</tr>
|
||
<tr>
|
||
<td><code>Emoji_Component</code></td>
|
||
<td rowspan="2"><a href="https://unicode.org/reports/tr51/#Emoji_Properties"><code>Emoji_Component</code></a></td>
|
||
</tr>
|
||
<tr>
|
||
<td><code>EComp</code></td>
|
||
</tr>
|
||
<tr>
|
||
<td><code>Emoji_Modifier</code></td>
|
||
<td rowspan="2"><a href="https://unicode.org/reports/tr51/#Emoji_Properties"><code>Emoji_Modifier</code></a></td>
|
||
</tr>
|
||
<tr>
|
||
<td><code>EMod</code></td>
|
||
</tr>
|
||
<tr>
|
||
<td><code>Emoji_Modifier_Base</code></td>
|
||
<td rowspan="2"><a href="https://unicode.org/reports/tr51/#Emoji_Properties"><code>Emoji_Modifier_Base</code></a></td>
|
||
</tr>
|
||
<tr>
|
||
<td><code>EBase</code></td>
|
||
</tr>
|
||
<tr>
|
||
<td><code>Emoji_Presentation</code></td>
|
||
<td rowspan="2"><a href="https://unicode.org/reports/tr51/#Emoji_Properties"><code>Emoji_Presentation</code></a></td>
|
||
</tr>
|
||
<tr>
|
||
<td><code>EPres</code></td>
|
||
</tr>
|
||
<tr>
|
||
<td><code>Extended_Pictographic</code></td>
|
||
<td rowspan="2"><a href="https://unicode.org/reports/tr51/#Emoji_Properties"><code>Extended_Pictographic</code></a></td>
|
||
</tr>
|
||
<tr>
|
||
<td><code>ExtPict</code></td>
|
||
</tr>
|
||
<tr>
|
||
<td><code>Extender</code></td>
|
||
<td rowspan="2"><a href="https://unicode.org/reports/tr44/#Extender"><code>Extender</code></a></td>
|
||
</tr>
|
||
<tr>
|
||
<td><code>Ext</code></td>
|
||
</tr>
|
||
<tr>
|
||
<td><code>Grapheme_Base</code></td>
|
||
<td rowspan="2"><a href="https://unicode.org/reports/tr44/#Grapheme_Base"><code>Grapheme_Base</code></a></td>
|
||
</tr>
|
||
<tr>
|
||
<td><code>Gr_Base</code></td>
|
||
</tr>
|
||
<tr>
|
||
<td><code>Grapheme_Extend</code></td>
|
||
<td rowspan="2"><a href="https://unicode.org/reports/tr44/#Grapheme_Extend"><code>Grapheme_Extend</code></a></td>
|
||
</tr>
|
||
<tr>
|
||
<td><code>Gr_Ext</code></td>
|
||
</tr>
|
||
<tr>
|
||
<td><code>Hex_Digit</code></td>
|
||
<td rowspan="2"><a href="https://unicode.org/reports/tr44/#Hex_Digit"><code>Hex_Digit</code></a></td>
|
||
</tr>
|
||
<tr>
|
||
<td><code>Hex</code></td>
|
||
</tr>
|
||
<tr>
|
||
<td><code>IDS_Binary_Operator</code></td>
|
||
<td rowspan="2"><a href="https://unicode.org/reports/tr44/#IDS_Binary_Operator"><code>IDS_Binary_Operator</code></a></td>
|
||
</tr>
|
||
<tr>
|
||
<td><code>IDSB</code></td>
|
||
</tr>
|
||
<tr>
|
||
<td><code>IDS_Trinary_Operator</code></td>
|
||
<td rowspan="2"><a href="https://unicode.org/reports/tr44/#IDS_Trinary_Operator"><code>IDS_Trinary_Operator</code></a></td>
|
||
</tr>
|
||
<tr>
|
||
<td><code>IDST</code></td>
|
||
</tr>
|
||
<tr>
|
||
<td><code>ID_Continue</code></td>
|
||
<td rowspan="2"><a href="https://unicode.org/reports/tr44/#ID_Continue"><code>ID_Continue</code></a></td>
|
||
</tr>
|
||
<tr>
|
||
<td><code>IDC</code></td>
|
||
</tr>
|
||
<tr>
|
||
<td><code>ID_Start</code></td>
|
||
<td rowspan="2"><a href="https://unicode.org/reports/tr44/#ID_Start"><code>ID_Start</code></a></td>
|
||
</tr>
|
||
<tr>
|
||
<td><code>IDS</code></td>
|
||
</tr>
|
||
<tr>
|
||
<td><code>Ideographic</code></td>
|
||
<td rowspan="2"><a href="https://unicode.org/reports/tr44/#Ideographic"><code>Ideographic</code></a></td>
|
||
</tr>
|
||
<tr>
|
||
<td><code>Ideo</code></td>
|
||
</tr>
|
||
<tr>
|
||
<td><code>Join_Control</code></td>
|
||
<td rowspan="2"><a href="https://unicode.org/reports/tr44/#Join_Control"><code>Join_Control</code></a></td>
|
||
</tr>
|
||
<tr>
|
||
<td><code>Join_C</code></td>
|
||
</tr>
|
||
<tr>
|
||
<td><code>Logical_Order_Exception</code></td>
|
||
<td rowspan="2"><a href="https://unicode.org/reports/tr44/#Logical_Order_Exception"><code>Logical_Order_Exception</code></a></td>
|
||
</tr>
|
||
<tr>
|
||
<td><code>LOE</code></td>
|
||
</tr>
|
||
<tr>
|
||
<td><code>Lowercase</code></td>
|
||
<td rowspan="2"><a href="https://unicode.org/reports/tr44/#Lowercase"><code>Lowercase</code></a></td>
|
||
</tr>
|
||
<tr>
|
||
<td><code>Lower</code></td>
|
||
</tr>
|
||
<tr>
|
||
<td><code>Math</code></td>
|
||
<td><a href="https://unicode.org/reports/tr44/#Math"><code>Math</code></a></td>
|
||
</tr>
|
||
<tr>
|
||
<td><code>Noncharacter_Code_Point</code></td>
|
||
<td rowspan="2"><a href="https://unicode.org/reports/tr44/#Noncharacter_Code_Point"><code>Noncharacter_Code_Point</code></a></td>
|
||
</tr>
|
||
<tr>
|
||
<td><code>NChar</code></td>
|
||
</tr>
|
||
<tr>
|
||
<td><code>Pattern_Syntax</code></td>
|
||
<td rowspan="2"><a href="https://unicode.org/reports/tr44/#Pattern_Syntax"><code>Pattern_Syntax</code></a></td>
|
||
</tr>
|
||
<tr>
|
||
<td><code>Pat_Syn</code></td>
|
||
</tr>
|
||
<tr>
|
||
<td><code>Pattern_White_Space</code></td>
|
||
<td rowspan="2"><a href="https://unicode.org/reports/tr44/#Pattern_White_Space"><code>Pattern_White_Space</code></a></td>
|
||
</tr>
|
||
<tr>
|
||
<td><code>Pat_WS</code></td>
|
||
</tr>
|
||
<tr>
|
||
<td><code>Quotation_Mark</code></td>
|
||
<td rowspan="2"><a href="https://unicode.org/reports/tr44/#Quotation_Mark"><code>Quotation_Mark</code></a></td>
|
||
</tr>
|
||
<tr>
|
||
<td><code>QMark</code></td>
|
||
</tr>
|
||
<tr>
|
||
<td><code>Radical</code></td>
|
||
<td><a href="https://unicode.org/reports/tr44/#Radical"><code>Radical</code></a></td>
|
||
</tr>
|
||
<tr>
|
||
<td><code>Regional_Indicator</code></td>
|
||
<td rowspan="2"><a href="https://unicode.org/reports/tr44/#Regional_Indicator"><code>Regional_Indicator</code></a></td>
|
||
</tr>
|
||
<tr>
|
||
<td><code>RI</code></td>
|
||
</tr>
|
||
<tr>
|
||
<td><code>Sentence_Terminal</code></td>
|
||
<td rowspan="2"><a href="https://unicode.org/reports/tr44/#STerm"><code>Sentence_Terminal</code></a></td>
|
||
</tr>
|
||
<tr>
|
||
<td><code>STerm</code></td>
|
||
</tr>
|
||
<tr>
|
||
<td><code>Soft_Dotted</code></td>
|
||
<td rowspan="2"><a href="https://unicode.org/reports/tr44/#Soft_Dotted"><code>Soft_Dotted</code></a></td>
|
||
</tr>
|
||
<tr>
|
||
<td><code>SD</code></td>
|
||
</tr>
|
||
<tr>
|
||
<td><code>Terminal_Punctuation</code></td>
|
||
<td rowspan="2"><a href="https://unicode.org/reports/tr44/#Terminal_Punctuation"><code>Terminal_Punctuation</code></a></td>
|
||
</tr>
|
||
<tr>
|
||
<td><code>Term</code></td>
|
||
</tr>
|
||
<tr>
|
||
<td><code>Unified_Ideograph</code></td>
|
||
<td rowspan="2"><a href="https://unicode.org/reports/tr44/#Unified_Ideograph"><code>Unified_Ideograph</code></a></td>
|
||
</tr>
|
||
<tr>
|
||
<td><code>UIdeo</code></td>
|
||
</tr>
|
||
<tr>
|
||
<td><code>Uppercase</code></td>
|
||
<td rowspan="2"><a href="https://unicode.org/reports/tr44/#Uppercase"><code>Uppercase</code></a></td>
|
||
</tr>
|
||
<tr>
|
||
<td><code>Upper</code></td>
|
||
</tr>
|
||
<tr>
|
||
<td><code>Variation_Selector</code></td>
|
||
<td rowspan="2"><a href="https://unicode.org/reports/tr44/#Variation_Selector"><code>Variation_Selector</code></a></td>
|
||
</tr>
|
||
<tr>
|
||
<td><code>VS</code></td>
|
||
</tr>
|
||
<tr>
|
||
<td><code>White_Space</code></td>
|
||
<td rowspan="2"><a href="https://unicode.org/reports/tr44/#White_Space"><code>White_Space</code></a></td>
|
||
</tr>
|
||
<tr>
|
||
<td><code>space</code></td>
|
||
</tr>
|
||
<tr>
|
||
<td><code>XID_Continue</code></td>
|
||
<td rowspan="2"><a href="https://unicode.org/reports/tr44/#XID_Continue"><code>XID_Continue</code></a></td>
|
||
</tr>
|
||
<tr>
|
||
<td><code>XIDC</code></td>
|
||
</tr>
|
||
<tr>
|
||
<td><code>XID_Start</code></td>
|
||
<td rowspan="2"><a href="https://unicode.org/reports/tr44/#XID_Start"><code>XID_Start</code></a></td>
|
||
</tr>
|
||
<tr>
|
||
<td><code>XIDS</code></td>
|
||
</tr>
|
||
</tbody></table>
|
||
</figure></emu-table>
|
||
|
||
<emu-table id="table-binary-unicode-properties-of-strings"><figure><figcaption>Table 66: Binary Unicode properties of strings</figcaption>
|
||
|
||
<table class="real-table unicode-property-table">
|
||
<thead>
|
||
<tr>
|
||
<th><emu-not-ref>Property name</emu-not-ref></th>
|
||
</tr>
|
||
</thead>
|
||
<tbody><tr>
|
||
<td><code>Basic_Emoji</code></td>
|
||
</tr>
|
||
<tr>
|
||
<td><code>Emoji_Keycap_Sequence</code></td>
|
||
</tr>
|
||
<tr>
|
||
<td><code>RGI_Emoji_Modifier_Sequence</code></td>
|
||
</tr>
|
||
<tr>
|
||
<td><code>RGI_Emoji_Flag_Sequence</code></td>
|
||
</tr>
|
||
<tr>
|
||
<td><code>RGI_Emoji_Tag_Sequence</code></td>
|
||
</tr>
|
||
<tr>
|
||
<td><code>RGI_Emoji_ZWJ_Sequence</code></td>
|
||
</tr>
|
||
<tr>
|
||
<td><code>RGI_Emoji</code></td>
|
||
</tr>
|
||
</tbody></table>
|
||
</figure></emu-table>
|
||
|
||
</emu-clause>
|
||
|
||
<emu-clause id="sec-runtime-semantics-unicodematchpropertyvalue-p-v" type="abstract operation" aoid="UnicodeMatchPropertyValue">
|
||
<h1><span class="secnum">22.2.2.9.8</span> UnicodeMatchPropertyValue ( <var>p</var>, <var>v</var> )</h1>
|
||
<p>The abstract operation UnicodeMatchPropertyValue takes arguments <var>p</var> (<emu-xref href="#sec-source-text" id="_ref_12232"><a href="ecmascript-language-source-code.html#sec-source-text">ECMAScript source text</a></emu-xref>) and <var>v</var> (<emu-xref href="#sec-source-text" id="_ref_12233"><a href="ecmascript-language-source-code.html#sec-source-text">ECMAScript source text</a></emu-xref>) and returns a Unicode property value. It performs the following steps when called:</p>
|
||
<emu-alg><ol><li><emu-xref href="#assert" id="_ref_12234"><a href="notational-conventions.html#assert">Assert</a></emu-xref>: <var>p</var> is a canonical, unaliased <emu-not-ref>Unicode property name</emu-not-ref> listed in the “<emu-not-ref>Canonical property name</emu-not-ref>” column of <emu-xref href="#table-nonbinary-unicode-properties" id="_ref_706"><a href="text-processing.html#table-nonbinary-unicode-properties">Table 64</a></emu-xref>.</li><li><emu-xref href="#assert" id="_ref_12235"><a href="notational-conventions.html#assert">Assert</a></emu-xref>: <var>v</var> is a property value or property value alias for the Unicode property <var>p</var> listed in <a href="https://unicode.org/Public/UCD/latest/ucd/PropertyValueAliases.txt"><code>PropertyValueAliases.txt</code></a>.</li><li>Let <var>value</var> be the canonical property value of <var>v</var> as given in the “Canonical property value” column of the corresponding row.</li><li>Return the <emu-xref href="#sec-list-and-record-specification-type" id="_ref_12236"><a href="ecmascript-data-types-and-values.html#sec-list-and-record-specification-type">List</a></emu-xref> of Unicode code points <var>value</var>.</li></ol></emu-alg>
|
||
<p>Implementations must support the Unicode property values and property value aliases listed in <a href="https://unicode.org/Public/UCD/latest/ucd/PropertyValueAliases.txt"><code>PropertyValueAliases.txt</code></a> for the properties listed in <emu-xref href="#table-nonbinary-unicode-properties" id="_ref_707"><a href="text-processing.html#table-nonbinary-unicode-properties">Table 64</a></emu-xref>. To ensure interoperability, implementations must not support any other property values or property value aliases.</p>
|
||
<emu-note><span class="note">Note 1</span><div class="note-contents">
|
||
<p>For example, <code>Xpeo</code> and <code>Old_Persian</code> are valid <code>Script_Extensions</code> values, but <code>xpeo</code> and <code>Old Persian</code> aren't.</p>
|
||
</div></emu-note>
|
||
<emu-note><span class="note">Note 2</span><div class="note-contents">
|
||
<p>This algorithm differs from <a href="https://unicode.org/reports/tr44/#Matching_Symbolic">the matching rules for symbolic values listed in UAX44</a>: case, <emu-xref href="#sec-white-space" id="_ref_708"><a href="ecmascript-language-lexical-grammar.html#sec-white-space">white space</a></emu-xref>, U+002D (HYPHEN-MINUS), and U+005F (LOW LINE) are not ignored, and the <code>Is</code> prefix is not supported.</p>
|
||
</div></emu-note>
|
||
</emu-clause>
|
||
</emu-clause>
|
||
|
||
<emu-clause id="sec-compileclasssetstring" type="sdo" aoid="CompileClassSetString">
|
||
<h1><span class="secnum">22.2.2.10</span> Runtime Semantics: CompileClassSetString</h1>
|
||
<p>The <emu-xref href="#sec-algorithm-conventions-syntax-directed-operations" id="_ref_12237"><a href="notational-conventions.html#sec-algorithm-conventions-syntax-directed-operations">syntax-directed operation</a></emu-xref> CompileClassSetString takes argument <var>rer</var> (a <emu-xref href="#sec-regexp-records" id="_ref_12238"><a href="text-processing.html#sec-regexp-records">RegExp Record</a></emu-xref>) and returns a sequence of characters. It is defined piecewise over the following productions:</p>
|
||
|
||
<emu-grammar><emu-production name="ClassString" type="lexical" collapsed="">
|
||
<emu-nt><a href="text-processing.html#prod-ClassString">ClassString</a></emu-nt> <emu-geq>::</emu-geq> <emu-rhs a="n7nathbb" id="prod-OhiYT-qV"><emu-gann>[empty]</emu-gann></emu-rhs>
|
||
</emu-production>
|
||
</emu-grammar>
|
||
<emu-alg><ol><li>Return an empty sequence of characters.</li></ol></emu-alg>
|
||
<emu-grammar><emu-production name="ClassString" type="lexical" collapsed="">
|
||
<emu-nt><a href="text-processing.html#prod-ClassString">ClassString</a></emu-nt> <emu-geq>::</emu-geq> <emu-rhs a="zzzearnw" id="prod-DqGvYEuY"><emu-nt id="_ref_24515"><a href="text-processing.html#prod-NonEmptyClassString">NonEmptyClassString</a></emu-nt></emu-rhs>
|
||
</emu-production>
|
||
</emu-grammar>
|
||
<emu-alg><ol><li>Return <emu-xref aoid="CompileClassSetString" id="_ref_12239"><a href="text-processing.html#sec-compileclasssetstring">CompileClassSetString</a></emu-xref> of <emu-nt id="_ref_24516"><a href="text-processing.html#prod-NonEmptyClassString">NonEmptyClassString</a></emu-nt> with argument <var>rer</var>.</li></ol></emu-alg>
|
||
<emu-grammar><emu-production name="NonEmptyClassString" type="lexical" collapsed="">
|
||
<emu-nt><a href="text-processing.html#prod-NonEmptyClassString">NonEmptyClassString</a></emu-nt> <emu-geq>::</emu-geq> <emu-rhs a="g-kpie7v" id="prod-ew3HL5wc">
|
||
<emu-nt id="_ref_24517"><a href="text-processing.html#prod-ClassSetCharacter">ClassSetCharacter</a></emu-nt>
|
||
<emu-nt optional="" id="_ref_24518"><a href="text-processing.html#prod-NonEmptyClassString">NonEmptyClassString</a><emu-mods><emu-opt>opt</emu-opt></emu-mods></emu-nt>
|
||
</emu-rhs>
|
||
</emu-production>
|
||
</emu-grammar>
|
||
<emu-alg><ol><li>Let <var>cs</var> be <emu-xref aoid="CompileToCharSet" id="_ref_12240"><a href="text-processing.html#sec-compiletocharset">CompileToCharSet</a></emu-xref> of <emu-nt id="_ref_24519"><a href="text-processing.html#prod-ClassSetCharacter">ClassSetCharacter</a></emu-nt> with argument <var>rer</var>.</li><li>Let <var>s1</var> be the sequence of characters that is the single <emu-xref href="#sec-pattern-notation" id="_ref_12241"><a href="text-processing.html#sec-pattern-notation">CharSetElement</a></emu-xref> of <var>cs</var>.</li><li>If <emu-nt id="_ref_24520"><a href="text-processing.html#prod-NonEmptyClassString">NonEmptyClassString</a></emu-nt> is present, then<ol><li>Let <var>s2</var> be <emu-xref aoid="CompileClassSetString" id="_ref_12242"><a href="text-processing.html#sec-compileclasssetstring">CompileClassSetString</a></emu-xref> of <emu-nt id="_ref_24521"><a href="text-processing.html#prod-NonEmptyClassString">NonEmptyClassString</a></emu-nt> with argument <var>rer</var>.</li><li>Return the concatenation of <var>s1</var> and <var>s2</var>.</li></ol></li><li>Return <var>s1</var>.</li></ol></emu-alg>
|
||
</emu-clause>
|
||
</emu-clause>
|
||
|
||
<emu-clause id="sec-abstract-operations-for-regexp-creation" oldids="sec-abstract-operations-for-the-regexp-constructor"><span id="sec-abstract-operations-for-the-regexp-constructor"></span>
|
||
<h1><span class="secnum">22.2.3</span> Abstract Operations for RegExp Creation</h1>
|
||
|
||
<emu-clause id="sec-regexpcreate" type="abstract operation" aoid="RegExpCreate">
|
||
<h1><span class="secnum">22.2.3.1</span> RegExpCreate ( <var>P</var>, <var>F</var> )</h1>
|
||
<p>The abstract operation RegExpCreate takes arguments <var>P</var> (an <emu-xref href="#sec-ecmascript-language-types" id="_ref_12243"><a href="ecmascript-data-types-and-values.html#sec-ecmascript-language-types">ECMAScript language value</a></emu-xref>) and <var>F</var> (a String or <emu-val>undefined</emu-val>) and returns either a <emu-xref href="#sec-completion-record-specification-type" id="_ref_12244"><a href="ecmascript-data-types-and-values.html#sec-completion-record-specification-type">normal completion containing</a></emu-xref> an Object or a <emu-xref href="#sec-completion-record-specification-type" id="_ref_12245"><a href="ecmascript-data-types-and-values.html#sec-completion-record-specification-type">throw completion</a></emu-xref>. It performs the following steps when called:</p>
|
||
<emu-alg><ol><li>Let <var>obj</var> be ! <emu-xref aoid="RegExpAlloc" id="_ref_12246"><a href="text-processing.html#sec-regexpalloc">RegExpAlloc</a></emu-xref>(<emu-xref href="#sec-regexp-constructor" id="_ref_12247"><a href="text-processing.html#sec-regexp-constructor">%RegExp%</a></emu-xref>).</li><li>Return ? <emu-xref aoid="RegExpInitialize" id="_ref_12248"><a href="text-processing.html#sec-regexpinitialize" class="e-user-code">RegExpInitialize</a></emu-xref>(<var>obj</var>, <var>P</var>, <var>F</var>).</li></ol></emu-alg>
|
||
</emu-clause>
|
||
|
||
<emu-clause id="sec-regexpalloc" type="abstract operation" aoid="RegExpAlloc">
|
||
<h1><span class="secnum">22.2.3.2</span> RegExpAlloc ( <var>newTarget</var> )</h1>
|
||
<p>The abstract operation RegExpAlloc takes argument <var>newTarget</var> (a <emu-xref href="#constructor" id="_ref_12249"><a href="ecmascript-data-types-and-values.html#constructor">constructor</a></emu-xref>) and returns either a <emu-xref href="#sec-completion-record-specification-type" id="_ref_12250"><a href="ecmascript-data-types-and-values.html#sec-completion-record-specification-type">normal completion containing</a></emu-xref> an Object or a <emu-xref href="#sec-completion-record-specification-type" id="_ref_12251"><a href="ecmascript-data-types-and-values.html#sec-completion-record-specification-type">throw completion</a></emu-xref>. It performs the following steps when called:</p>
|
||
<emu-alg><ol><li>Let <var>obj</var> be ? <emu-xref aoid="OrdinaryCreateFromConstructor" id="_ref_12252"><a href="ordinary-and-exotic-objects-behaviours.html#sec-ordinarycreatefromconstructor" class="e-user-code">OrdinaryCreateFromConstructor</a></emu-xref>(<var>newTarget</var>, <emu-val>"%RegExp.prototype%"</emu-val>, « <var class="field">[[OriginalSource]]</var>, <var class="field">[[OriginalFlags]]</var>, <var class="field">[[RegExpRecord]]</var>, <var class="field">[[RegExpMatcher]]</var> »).</li><li>Perform ! <emu-xref aoid="DefinePropertyOrThrow" id="_ref_12253"><a href="abstract-operations.html#sec-definepropertyorthrow">DefinePropertyOrThrow</a></emu-xref>(<var>obj</var>, <emu-val>"lastIndex"</emu-val>, PropertyDescriptor { <var class="field">[[Writable]]</var>: <emu-val>true</emu-val>, <var class="field">[[Enumerable]]</var>: <emu-val>false</emu-val>, <var class="field">[[Configurable]]</var>: <emu-val>false</emu-val> }).</li><li>Return <var>obj</var>.</li></ol></emu-alg>
|
||
</emu-clause>
|
||
|
||
<emu-clause id="sec-regexpinitialize" type="abstract operation" aoid="RegExpInitialize">
|
||
<h1><span class="secnum">22.2.3.3</span> RegExpInitialize ( <var>obj</var>, <var>pattern</var>, <var>flags</var> )</h1>
|
||
<p>The abstract operation RegExpInitialize takes arguments <var>obj</var> (an Object), <var>pattern</var> (an <emu-xref href="#sec-ecmascript-language-types" id="_ref_12254"><a href="ecmascript-data-types-and-values.html#sec-ecmascript-language-types">ECMAScript language value</a></emu-xref>), and <var>flags</var> (an <emu-xref href="#sec-ecmascript-language-types" id="_ref_12255"><a href="ecmascript-data-types-and-values.html#sec-ecmascript-language-types">ECMAScript language value</a></emu-xref>) and returns either a <emu-xref href="#sec-completion-record-specification-type" id="_ref_12256"><a href="ecmascript-data-types-and-values.html#sec-completion-record-specification-type">normal completion containing</a></emu-xref> an Object or a <emu-xref href="#sec-completion-record-specification-type" id="_ref_12257"><a href="ecmascript-data-types-and-values.html#sec-completion-record-specification-type">throw completion</a></emu-xref>. It performs the following steps when called:</p>
|
||
<emu-alg><ol><li>If <var>pattern</var> is <emu-val>undefined</emu-val>, let <var>P</var> be the empty String.</li><li>Else, let <var>P</var> be ? <emu-xref aoid="ToString" id="_ref_12258"><a href="abstract-operations.html#sec-tostring" class="e-user-code">ToString</a></emu-xref>(<var>pattern</var>).</li><li>If <var>flags</var> is <emu-val>undefined</emu-val>, let <var>F</var> be the empty String.</li><li>Else, let <var>F</var> be ? <emu-xref aoid="ToString" id="_ref_12259"><a href="abstract-operations.html#sec-tostring" class="e-user-code">ToString</a></emu-xref>(<var>flags</var>).</li><li>If <var>F</var> contains any code unit other than <emu-val>"d"</emu-val>, <emu-val>"g"</emu-val>, <emu-val>"i"</emu-val>, <emu-val>"m"</emu-val>, <emu-val>"s"</emu-val>, <emu-val>"u"</emu-val>, <emu-val>"v"</emu-val>, or <emu-val>"y"</emu-val>, or if <var>F</var> contains any code unit more than once, throw a <emu-val>SyntaxError</emu-val> exception.</li><li>If <var>F</var> contains <emu-val>"i"</emu-val>, let <var>i</var> be <emu-val>true</emu-val>; else let <var>i</var> be <emu-val>false</emu-val>.</li><li>If <var>F</var> contains <emu-val>"m"</emu-val>, let <var>m</var> be <emu-val>true</emu-val>; else let <var>m</var> be <emu-val>false</emu-val>.</li><li>If <var>F</var> contains <emu-val>"s"</emu-val>, let <var>s</var> be <emu-val>true</emu-val>; else let <var>s</var> be <emu-val>false</emu-val>.</li><li>If <var>F</var> contains <emu-val>"u"</emu-val>, let <var>u</var> be <emu-val>true</emu-val>; else let <var>u</var> be <emu-val>false</emu-val>.</li><li>If <var>F</var> contains <emu-val>"v"</emu-val>, let <var>v</var> be <emu-val>true</emu-val>; else let <var>v</var> be <emu-val>false</emu-val>.</li><li>If <var>u</var> is <emu-val>true</emu-val> or <var>v</var> is <emu-val>true</emu-val>, then<ol><li>Let <var>patternText</var> be <emu-xref aoid="StringToCodePoints" id="_ref_12260"><a href="ecmascript-language-source-code.html#sec-stringtocodepoints">StringToCodePoints</a></emu-xref>(<var>P</var>).</li></ol></li><li>Else,<ol><li>Let <var>patternText</var> be the result of interpreting each of <var>P</var>'s 16-bit elements as a Unicode BMP code point. UTF-16 decoding is not applied to the elements.</li></ol></li><li>Let <var>parseResult</var> be <emu-xref aoid="ParsePattern" id="_ref_12261"><a href="text-processing.html#sec-parsepattern">ParsePattern</a></emu-xref>(<var>patternText</var>, <var>u</var>, <var>v</var>).</li><li>If <var>parseResult</var> is a non-empty <emu-xref href="#sec-list-and-record-specification-type" id="_ref_12262"><a href="ecmascript-data-types-and-values.html#sec-list-and-record-specification-type">List</a></emu-xref> of <emu-val>SyntaxError</emu-val> objects, throw a <emu-val>SyntaxError</emu-val> exception.</li><li><emu-xref href="#assert" id="_ref_12263"><a href="notational-conventions.html#assert">Assert</a></emu-xref>: <var>parseResult</var> is a <emu-nt id="_ref_24522"><a href="text-processing.html#prod-Pattern">Pattern</a></emu-nt> <emu-xref href="#sec-syntactic-grammar" id="_ref_12264"><a href="notational-conventions.html#sec-syntactic-grammar">Parse Node</a></emu-xref>.</li><li>Set <var>obj</var>.<var class="field">[[OriginalSource]]</var> to <var>P</var>.</li><li>Set <var>obj</var>.<var class="field">[[OriginalFlags]]</var> to <var>F</var>.</li><li>Let <var>capturingGroupsCount</var> be <emu-xref aoid="CountLeftCapturingParensWithin" id="_ref_12265"><a href="text-processing.html#sec-countleftcapturingparenswithin">CountLeftCapturingParensWithin</a></emu-xref>(<var>parseResult</var>).</li><li>Let <var>rer</var> be the <emu-xref href="#sec-regexp-records" id="_ref_12266"><a href="text-processing.html#sec-regexp-records">RegExp Record</a></emu-xref> { <var class="field">[[IgnoreCase]]</var>: <var>i</var>, <var class="field">[[Multiline]]</var>: <var>m</var>, <var class="field">[[DotAll]]</var>: <var>s</var>, <var class="field">[[Unicode]]</var>: <var>u</var>, <var class="field">[[UnicodeSets]]</var>: <var>v</var>, <var class="field">[[CapturingGroupsCount]]</var>: <var>capturingGroupsCount</var> }.</li><li>Set <var>obj</var>.<var class="field">[[RegExpRecord]]</var> to <var>rer</var>.</li><li>Set <var>obj</var>.<var class="field">[[RegExpMatcher]]</var> to <emu-xref aoid="CompilePattern" id="_ref_12267"><a href="text-processing.html#sec-compilepattern">CompilePattern</a></emu-xref> of <var>parseResult</var> with argument <var>rer</var>.</li><li>Perform ? <emu-xref aoid="Set" id="_ref_12268"><a href="abstract-operations.html#sec-set-o-p-v-throw">Set</a></emu-xref>(<var>obj</var>, <emu-val>"lastIndex"</emu-val>, <emu-val>+0</emu-val><sub>𝔽</sub>, <emu-val>true</emu-val>).</li><li>Return <var>obj</var>.</li></ol></emu-alg>
|
||
</emu-clause>
|
||
|
||
<emu-clause id="sec-parsepattern" type="abstract operation" aoid="ParsePattern">
|
||
<h1><span class="secnum">22.2.3.4</span> Static Semantics: ParsePattern ( <var>patternText</var>, <var>u</var>, <var>v</var> )</h1>
|
||
<p>The abstract operation ParsePattern takes arguments <var>patternText</var> (a sequence of Unicode code points), <var>u</var> (a Boolean), and <var>v</var> (a Boolean) and returns a <emu-xref href="#sec-syntactic-grammar" id="_ref_12269"><a href="notational-conventions.html#sec-syntactic-grammar">Parse Node</a></emu-xref> or a non-empty <emu-xref href="#sec-list-and-record-specification-type" id="_ref_12270"><a href="ecmascript-data-types-and-values.html#sec-list-and-record-specification-type">List</a></emu-xref> of <emu-val>SyntaxError</emu-val> objects.</p>
|
||
<emu-note><span class="note">Note</span><div class="note-contents">
|
||
<p>This section is amended in <emu-xref href="#sec-parsepattern-annexb" id="_ref_709"><a href="additional-ecmascript-features-for-web-browsers.html#sec-parsepattern-annexb">B.1.2.9</a></emu-xref>.</p>
|
||
</div></emu-note>
|
||
<p>It performs the following steps when called:</p>
|
||
<emu-alg><ol><li>If <var>v</var> is <emu-val>true</emu-val> and <var>u</var> is <emu-val>true</emu-val>, then<ol><li>Let <var>parseResult</var> be a <emu-xref href="#sec-list-and-record-specification-type" id="_ref_12271"><a href="ecmascript-data-types-and-values.html#sec-list-and-record-specification-type">List</a></emu-xref> containing one or more <emu-val>SyntaxError</emu-val> objects.</li></ol></li><li>Else if <var>v</var> is <emu-val>true</emu-val>, then<ol><li>Let <var>parseResult</var> be <emu-xref aoid="ParseText" id="_ref_12272"><a href="ecmascript-language-source-code.html#sec-parsetext">ParseText</a></emu-xref>(<var>patternText</var>, <emu-nt params="+UnicodeMode, +UnicodeSetsMode, +NamedCaptureGroups" id="_ref_24523"><a href="text-processing.html#prod-Pattern">Pattern</a><emu-mods><emu-params>[+UnicodeMode, +UnicodeSetsMode, +NamedCaptureGroups]</emu-params></emu-mods></emu-nt>).</li></ol></li><li>Else if <var>u</var> is <emu-val>true</emu-val>, then<ol><li>Let <var>parseResult</var> be <emu-xref aoid="ParseText" id="_ref_12273"><a href="ecmascript-language-source-code.html#sec-parsetext">ParseText</a></emu-xref>(<var>patternText</var>, <emu-nt params="+UnicodeMode, ~UnicodeSetsMode, +NamedCaptureGroups" id="_ref_24524"><a href="text-processing.html#prod-Pattern">Pattern</a><emu-mods><emu-params>[+UnicodeMode, ~UnicodeSetsMode, +NamedCaptureGroups]</emu-params></emu-mods></emu-nt>).</li></ol></li><li>Else,<ol><li>Let <var>parseResult</var> be <emu-xref aoid="ParseText" id="_ref_12274"><a href="ecmascript-language-source-code.html#sec-parsetext">ParseText</a></emu-xref>(<var>patternText</var>, <emu-nt params="~UnicodeMode, ~UnicodeSetsMode, +NamedCaptureGroups" id="_ref_24525"><a href="text-processing.html#prod-Pattern">Pattern</a><emu-mods><emu-params>[~UnicodeMode, ~UnicodeSetsMode, +NamedCaptureGroups]</emu-params></emu-mods></emu-nt>).</li></ol></li><li>Return <var>parseResult</var>.</li></ol></emu-alg>
|
||
</emu-clause>
|
||
</emu-clause>
|
||
|
||
<emu-clause id="sec-regexp-constructor">
|
||
<h1><span class="secnum">22.2.4</span> The RegExp Constructor</h1>
|
||
<p>The RegExp <emu-xref href="#constructor" id="_ref_12275"><a href="ecmascript-data-types-and-values.html#constructor">constructor</a></emu-xref>:</p>
|
||
<ul>
|
||
<li>is <dfn tabindex="-1">%RegExp%</dfn>.</li>
|
||
<li>is the initial value of the <emu-val>"RegExp"</emu-val> property of the <emu-xref href="#sec-global-object" id="_ref_12276"><a href="global-object.html#sec-global-object">global object</a></emu-xref>.</li>
|
||
<li>creates and initializes a new RegExp object when called as a <emu-xref href="#constructor" id="_ref_12277"><a href="ecmascript-data-types-and-values.html#constructor">constructor</a></emu-xref>.</li>
|
||
<li>when called as a function rather than as a <emu-xref href="#constructor" id="_ref_12278"><a href="ecmascript-data-types-and-values.html#constructor">constructor</a></emu-xref>, returns either a new RegExp object, or the argument itself if the only argument is a RegExp object.</li>
|
||
<li>may be used as the value of an <code>extends</code> clause of a class definition. Subclass <emu-xref href="#constructor" id="_ref_12279"><a href="ecmascript-data-types-and-values.html#constructor">constructors</a></emu-xref> that intend to inherit the specified RegExp behaviour must include a <code>super</code> call to the RegExp <emu-xref href="#constructor" id="_ref_12280"><a href="ecmascript-data-types-and-values.html#constructor">constructor</a></emu-xref> to create and initialize subclass instances with the necessary internal slots.</li>
|
||
</ul>
|
||
|
||
<emu-clause id="sec-regexp-pattern-flags" type="built-in function">
|
||
<h1><span class="secnum">22.2.4.1</span> RegExp ( <var>pattern</var>, <var>flags</var> )</h1>
|
||
<p>This function performs the following steps when called:</p>
|
||
<emu-alg><ol><li>Let <var>patternIsRegExp</var> be ? <emu-xref aoid="IsRegExp" id="_ref_12281"><a href="abstract-operations.html#sec-isregexp" class="e-user-code">IsRegExp</a></emu-xref>(<var>pattern</var>).</li><li>If NewTarget is <emu-val>undefined</emu-val>, then<ol><li>Let <var>newTarget</var> be the <emu-xref href="#active-function-object" id="_ref_12282"><a href="executable-code-and-execution-contexts.html#active-function-object">active function object</a></emu-xref>.</li><li>If <var>patternIsRegExp</var> is <emu-val>true</emu-val> and <var>flags</var> is <emu-val>undefined</emu-val>, then<ol><li>Let <var>patternConstructor</var> be ? <emu-xref aoid="Get" id="_ref_12283"><a href="abstract-operations.html#sec-get-o-p" class="e-user-code">Get</a></emu-xref>(<var>pattern</var>, <emu-val>"constructor"</emu-val>).</li><li>If <emu-xref aoid="SameValue" id="_ref_12284"><a href="abstract-operations.html#sec-samevalue">SameValue</a></emu-xref>(<var>newTarget</var>, <var>patternConstructor</var>) is <emu-val>true</emu-val>, return <var>pattern</var>.</li></ol></li></ol></li><li>Else,<ol><li>Let <var>newTarget</var> be NewTarget.</li></ol></li><li>If <var>pattern</var> <emu-xref href="#sec-object-type" id="_ref_12285"><a href="ecmascript-data-types-and-values.html#sec-object-type">is an Object</a></emu-xref> and <var>pattern</var> has a <var class="field">[[RegExpMatcher]]</var> internal slot, then<ol><li>Let <var>P</var> be <var>pattern</var>.<var class="field">[[OriginalSource]]</var>.</li><li>If <var>flags</var> is <emu-val>undefined</emu-val>, let <var>F</var> be <var>pattern</var>.<var class="field">[[OriginalFlags]]</var>.</li><li>Else, let <var>F</var> be <var>flags</var>.</li></ol></li><li>Else if <var>patternIsRegExp</var> is <emu-val>true</emu-val>, then<ol><li>Let <var>P</var> be ? <emu-xref aoid="Get" id="_ref_12286"><a href="abstract-operations.html#sec-get-o-p" class="e-user-code">Get</a></emu-xref>(<var>pattern</var>, <emu-val>"source"</emu-val>).</li><li>If <var>flags</var> is <emu-val>undefined</emu-val>, then<ol><li>Let <var>F</var> be ? <emu-xref aoid="Get" id="_ref_12287"><a href="abstract-operations.html#sec-get-o-p" class="e-user-code">Get</a></emu-xref>(<var>pattern</var>, <emu-val>"flags"</emu-val>).</li></ol></li><li>Else,<ol><li>Let <var>F</var> be <var>flags</var>.</li></ol></li></ol></li><li>Else,<ol><li>Let <var>P</var> be <var>pattern</var>.</li><li>Let <var>F</var> be <var>flags</var>.</li></ol></li><li>Let <var>O</var> be ? <emu-xref aoid="RegExpAlloc" id="_ref_12288"><a href="text-processing.html#sec-regexpalloc" class="e-user-code">RegExpAlloc</a></emu-xref>(<var>newTarget</var>).</li><li>Return ? <emu-xref aoid="RegExpInitialize" id="_ref_12289"><a href="text-processing.html#sec-regexpinitialize" class="e-user-code">RegExpInitialize</a></emu-xref>(<var>O</var>, <var>P</var>, <var>F</var>).</li></ol></emu-alg>
|
||
<emu-note><span class="note">Note</span><div class="note-contents">
|
||
<p>If pattern is supplied using a <emu-nt id="_ref_24526"><a href="ecmascript-language-lexical-grammar.html#prod-StringLiteral">StringLiteral</a></emu-nt>, the usual escape sequence substitutions are performed before the String is processed by this function. If pattern must contain an escape sequence to be recognized by this function, any U+005C (REVERSE SOLIDUS) code points must be escaped within the <emu-nt id="_ref_24527"><a href="ecmascript-language-lexical-grammar.html#prod-StringLiteral">StringLiteral</a></emu-nt> to prevent them being removed when the contents of the <emu-nt id="_ref_24528"><a href="ecmascript-language-lexical-grammar.html#prod-StringLiteral">StringLiteral</a></emu-nt> are formed.</p>
|
||
</div></emu-note>
|
||
</emu-clause>
|
||
</emu-clause>
|
||
|
||
<emu-clause id="sec-properties-of-the-regexp-constructor">
|
||
<h1><span class="secnum">22.2.5</span> Properties of the RegExp Constructor</h1>
|
||
<p>The RegExp <emu-xref href="#constructor" id="_ref_12290"><a href="ecmascript-data-types-and-values.html#constructor">constructor</a></emu-xref>:</p>
|
||
<ul>
|
||
<li>has a <var class="field">[[Prototype]]</var> internal slot whose value is <emu-xref href="#sec-properties-of-the-function-prototype-object" id="_ref_12291"><a href="fundamental-objects.html#sec-properties-of-the-function-prototype-object">%Function.prototype%</a></emu-xref>.</li>
|
||
<li>has the following properties:</li>
|
||
</ul>
|
||
|
||
<emu-clause id="sec-regexp.escape" type="built-in function">
|
||
<h1><span class="secnum">22.2.5.1</span> RegExp.escape ( <var>S</var> )</h1>
|
||
<p>This function returns a copy of <var>S</var> in which characters that are potentially special in a regular expression <emu-nt id="_ref_24529"><a href="text-processing.html#prod-Pattern">Pattern</a></emu-nt> have been replaced by equivalent escape sequences.</p>
|
||
<p>It performs the following steps when called:</p>
|
||
|
||
<emu-alg><ol><li>If <var>S</var> <emu-xref href="#sec-ecmascript-language-types-string-type" id="_ref_12292"><a href="ecmascript-data-types-and-values.html#sec-ecmascript-language-types-string-type">is not a String</a></emu-xref>, throw a <emu-val>TypeError</emu-val> exception.</li><li>Let <var>escaped</var> be the empty String.</li><li>Let <var>cpList</var> be <emu-xref aoid="StringToCodePoints" id="_ref_12293"><a href="ecmascript-language-source-code.html#sec-stringtocodepoints">StringToCodePoints</a></emu-xref>(<var>S</var>).</li><li>For each code point <var>cp</var> of <var>cpList</var>, do<ol><li>If <var>escaped</var> is the empty String and <var>cp</var> is matched by either <emu-nt id="_ref_24530"><a href="ecmascript-language-lexical-grammar.html#prod-DecimalDigit">DecimalDigit</a></emu-nt> or <emu-nt id="_ref_24531"><a href="ecmascript-language-lexical-grammar.html#prod-AsciiLetter">AsciiLetter</a></emu-nt>, then<ol><li>NOTE: Escaping a leading digit ensures that output corresponds with pattern text which may be used after a <code>\0</code> character escape or a <emu-nt id="_ref_24532"><a href="text-processing.html#prod-DecimalEscape">DecimalEscape</a></emu-nt> such as <code>\1</code> and still match <var>S</var> rather than be interpreted as an extension of the preceding escape sequence. Escaping a leading ASCII letter does the same for the context after <code>\c</code>.</li><li>Let <var>numericValue</var> be the numeric value of <var>cp</var>.</li><li>Let <var>hex</var> be <emu-xref aoid="Number::toString" id="_ref_12294"><a href="ecmascript-data-types-and-values.html#sec-numeric-types-number-tostring">Number::toString</a></emu-xref>(<emu-xref aoid="𝔽" id="_ref_12295"><a href="notational-conventions.html#%F0%9D%94%BD">𝔽</a></emu-xref>(<var>numericValue</var>), 16).</li><li><emu-xref href="#assert" id="_ref_12296"><a href="notational-conventions.html#assert">Assert</a></emu-xref>: The length of <var>hex</var> is 2.</li><li>Set <var>escaped</var> to the <emu-xref href="#string-concatenation" id="_ref_12297"><a href="ecmascript-data-types-and-values.html#string-concatenation">string-concatenation</a></emu-xref> of the code unit 0x005C (REVERSE SOLIDUS), <emu-val>"x"</emu-val>, and <var>hex</var>.</li></ol></li><li>Else,<ol><li>Set <var>escaped</var> to the <emu-xref href="#string-concatenation" id="_ref_12298"><a href="ecmascript-data-types-and-values.html#string-concatenation">string-concatenation</a></emu-xref> of <var>escaped</var> and <emu-xref aoid="EncodeForRegExpEscape" id="_ref_12299"><a href="text-processing.html#sec-encodeforregexpescape">EncodeForRegExpEscape</a></emu-xref>(<var>cp</var>).</li></ol></li></ol></li><li>Return <var>escaped</var>.</li></ol></emu-alg>
|
||
|
||
<emu-note><span class="note">Note</span><div class="note-contents">
|
||
<p>Despite having similar names, <emu-xref aoid="EscapeRegExpPattern" id="_ref_12300"><a href="text-processing.html#sec-escaperegexppattern">EscapeRegExpPattern</a></emu-xref> and <code>RegExp.escape</code> do not perform similar actions. The former escapes a pattern for representation as a string, while this function escapes a string for representation inside a pattern.</p>
|
||
</div></emu-note>
|
||
|
||
<emu-clause id="sec-encodeforregexpescape" type="abstract operation" aoid="EncodeForRegExpEscape">
|
||
<h1><span class="secnum">22.2.5.1.1</span> EncodeForRegExpEscape ( <var>cp</var> )</h1>
|
||
<p>The abstract operation EncodeForRegExpEscape takes argument <var>cp</var> (a code point) and returns a String. It returns a String representing a <emu-nt id="_ref_24533"><a href="text-processing.html#prod-Pattern">Pattern</a></emu-nt> for matching <var>cp</var>. If <var>cp</var> is white space or an ASCII punctuator, the returned value is an escape sequence. Otherwise, the returned value <emu-xref href="#sec-ecmascript-language-types-string-type" id="_ref_12301"><a href="ecmascript-data-types-and-values.html#sec-ecmascript-language-types-string-type">is a String</a></emu-xref> representation of <var>cp</var> itself. It performs the following steps when called:</p>
|
||
|
||
<emu-alg><ol><li>If <var>cp</var> is matched by <emu-nt id="_ref_24534"><a href="text-processing.html#prod-SyntaxCharacter">SyntaxCharacter</a></emu-nt> or <var>cp</var> is U+002F (SOLIDUS), then<ol><li>Return the <emu-xref href="#string-concatenation" id="_ref_12302"><a href="ecmascript-data-types-and-values.html#string-concatenation">string-concatenation</a></emu-xref> of 0x005C (REVERSE SOLIDUS) and <emu-xref aoid="UTF16EncodeCodePoint" id="_ref_12303"><a href="ecmascript-language-source-code.html#sec-utf16encodecodepoint">UTF16EncodeCodePoint</a></emu-xref>(<var>cp</var>).</li></ol></li><li>If <var>cp</var> is a code point listed in the “Code Point” column of <emu-xref href="#table-controlescape-code-point-values" id="_ref_710"><a href="text-processing.html#table-controlescape-code-point-values">Table 62</a></emu-xref>, then<ol><li>Return the <emu-xref href="#string-concatenation" id="_ref_12304"><a href="ecmascript-data-types-and-values.html#string-concatenation">string-concatenation</a></emu-xref> of 0x005C (REVERSE SOLIDUS) and the string in the “ControlEscape” column of the row whose “Code Point” column contains <var>cp</var>.</li></ol></li><li>Let <var>otherPunctuators</var> be the <emu-xref href="#string-concatenation" id="_ref_12305"><a href="ecmascript-data-types-and-values.html#string-concatenation">string-concatenation</a></emu-xref> of <emu-val>",-=<>#&!%:;@~'`"</emu-val> and the code unit 0x0022 (QUOTATION MARK).</li><li>Let <var>toEscape</var> be <emu-xref aoid="StringToCodePoints" id="_ref_12306"><a href="ecmascript-language-source-code.html#sec-stringtocodepoints">StringToCodePoints</a></emu-xref>(<var>otherPunctuators</var>).</li><li>If <var>toEscape</var> contains <var>cp</var>, <var>cp</var> is matched by either <emu-nt id="_ref_24535"><a href="ecmascript-language-lexical-grammar.html#prod-WhiteSpace">WhiteSpace</a></emu-nt> or <emu-nt id="_ref_24536"><a href="ecmascript-language-lexical-grammar.html#prod-LineTerminator">LineTerminator</a></emu-nt>, or <var>cp</var> has the same numeric value as a <emu-xref href="#leading-surrogate" id="_ref_12307"><a href="ecmascript-data-types-and-values.html#leading-surrogate">leading surrogate</a></emu-xref> or <emu-xref href="#trailing-surrogate" id="_ref_12308"><a href="ecmascript-data-types-and-values.html#trailing-surrogate">trailing surrogate</a></emu-xref>, then<ol><li>Let <var>cpNum</var> be the numeric value of <var>cp</var>.</li><li>If <var>cpNum</var> ≤ 0xFF, then<ol><li>Let <var>hex</var> be <emu-xref aoid="Number::toString" id="_ref_12309"><a href="ecmascript-data-types-and-values.html#sec-numeric-types-number-tostring">Number::toString</a></emu-xref>(<emu-xref aoid="𝔽" id="_ref_12310"><a href="notational-conventions.html#%F0%9D%94%BD">𝔽</a></emu-xref>(<var>cpNum</var>), 16).</li><li>Return the <emu-xref href="#string-concatenation" id="_ref_12311"><a href="ecmascript-data-types-and-values.html#string-concatenation">string-concatenation</a></emu-xref> of the code unit 0x005C (REVERSE SOLIDUS), <emu-val>"x"</emu-val>, and <emu-xref aoid="StringPad" id="_ref_12312"><a href="text-processing.html#sec-stringpad">StringPad</a></emu-xref>(<var>hex</var>, 2, <emu-val>"0"</emu-val>, <emu-const>start</emu-const>).</li></ol></li><li>Let <var>escaped</var> be the empty String.</li><li>Let <var>codeUnits</var> be <emu-xref aoid="UTF16EncodeCodePoint" id="_ref_12313"><a href="ecmascript-language-source-code.html#sec-utf16encodecodepoint">UTF16EncodeCodePoint</a></emu-xref>(<var>cp</var>).</li><li>For each code unit <var>cu</var> of <var>codeUnits</var>, do<ol><li>Set <var>escaped</var> to the <emu-xref href="#string-concatenation" id="_ref_12314"><a href="ecmascript-data-types-and-values.html#string-concatenation">string-concatenation</a></emu-xref> of <var>escaped</var> and <emu-xref aoid="UnicodeEscape" id="_ref_12315"><a href="structured-data.html#sec-unicodeescape">UnicodeEscape</a></emu-xref>(<var>cu</var>).</li></ol></li><li>Return <var>escaped</var>.</li></ol></li><li>Return <emu-xref aoid="UTF16EncodeCodePoint" id="_ref_12316"><a href="ecmascript-language-source-code.html#sec-utf16encodecodepoint">UTF16EncodeCodePoint</a></emu-xref>(<var>cp</var>).</li></ol></emu-alg>
|
||
</emu-clause>
|
||
</emu-clause>
|
||
|
||
<emu-clause id="sec-regexp.prototype">
|
||
<h1><span class="secnum">22.2.5.2</span> RegExp.prototype</h1>
|
||
<p>The initial value of <code>RegExp.prototype</code> is the <emu-xref href="#sec-properties-of-the-regexp-prototype-object" id="_ref_12317"><a href="text-processing.html#sec-properties-of-the-regexp-prototype-object">RegExp prototype object</a></emu-xref>.</p>
|
||
<p>This property has the attributes { <var class="field">[[Writable]]</var>: <emu-val>false</emu-val>, <var class="field">[[Enumerable]]</var>: <emu-val>false</emu-val>, <var class="field">[[Configurable]]</var>: <emu-val>false</emu-val> }.</p>
|
||
</emu-clause>
|
||
|
||
<emu-clause oldids="sec-get-regexp-@@species" id="sec-get-regexp-%symbol.species%" type="built-in function"><span id="sec-get-regexp-@@species"></span>
|
||
<h1><span class="secnum">22.2.5.3</span> get RegExp [ %Symbol.species% ]</h1>
|
||
<p><code>RegExp[%Symbol.species%]</code> is an <emu-xref href="#sec-object-type" id="_ref_12318"><a href="ecmascript-data-types-and-values.html#sec-object-type">accessor property</a></emu-xref> whose set accessor function is <emu-val>undefined</emu-val>. Its get accessor function performs the following steps when called:</p>
|
||
<emu-alg><ol><li>Return the <emu-val>this</emu-val> value.</li></ol></emu-alg>
|
||
<p>The value of the <emu-val>"name"</emu-val> property of this function is <emu-val>"get [Symbol.species]"</emu-val>.</p>
|
||
<emu-note><span class="note">Note</span><div class="note-contents">
|
||
<p>RegExp prototype methods normally use their <emu-val>this</emu-val> value's <emu-xref href="#constructor" id="_ref_12319"><a href="ecmascript-data-types-and-values.html#constructor">constructor</a></emu-xref> to create a derived object. However, a subclass <emu-xref href="#constructor" id="_ref_12320"><a href="ecmascript-data-types-and-values.html#constructor">constructor</a></emu-xref> may over-ride that default behaviour by redefining its <emu-xref href="#sec-well-known-symbols" id="_ref_12321"><a href="ecmascript-data-types-and-values.html#sec-well-known-symbols">%Symbol.species%</a></emu-xref> property.</p>
|
||
</div></emu-note>
|
||
</emu-clause>
|
||
</emu-clause>
|
||
|
||
<emu-clause id="sec-properties-of-the-regexp-prototype-object">
|
||
<h1><span class="secnum">22.2.6</span> Properties of the RegExp Prototype Object</h1>
|
||
<p>The <dfn tabindex="-1">RegExp prototype object</dfn>:</p>
|
||
<ul>
|
||
<li>is <dfn tabindex="-1">%RegExp.prototype%</dfn>.</li>
|
||
<li>is an <emu-xref href="#ordinary-object" id="_ref_12322"><a href="ecmascript-data-types-and-values.html#ordinary-object">ordinary object</a></emu-xref>.</li>
|
||
<li>is not a RegExp instance and does not have a <var class="field">[[RegExpMatcher]]</var> internal slot or any of the other internal slots of RegExp instance objects.</li>
|
||
<li>has a <var class="field">[[Prototype]]</var> internal slot whose value is <emu-xref href="#sec-properties-of-the-object-prototype-object" id="_ref_12323"><a href="fundamental-objects.html#sec-properties-of-the-object-prototype-object">%Object.prototype%</a></emu-xref>.</li>
|
||
</ul>
|
||
<emu-note><span class="note">Note</span><div class="note-contents">
|
||
<p>The RegExp prototype object does not have a <emu-val>"valueOf"</emu-val> property of its own; however, it inherits the <emu-val>"valueOf"</emu-val> property from the <emu-xref href="#sec-properties-of-the-object-prototype-object" id="_ref_12324"><a href="fundamental-objects.html#sec-properties-of-the-object-prototype-object">Object prototype object</a></emu-xref>.</p>
|
||
</div></emu-note>
|
||
|
||
<emu-clause id="sec-regexp.prototype.constructor">
|
||
<h1><span class="secnum">22.2.6.1</span> RegExp.prototype.constructor</h1>
|
||
<p>The initial value of <code>RegExp.prototype.constructor</code> is <emu-xref href="#sec-regexp-constructor" id="_ref_12325"><a href="text-processing.html#sec-regexp-constructor">%RegExp%</a></emu-xref>.</p>
|
||
</emu-clause>
|
||
|
||
<emu-clause id="sec-regexp.prototype.exec" type="built-in function">
|
||
<h1><span class="secnum">22.2.6.2</span> RegExp.prototype.exec ( <var>string</var> )</h1>
|
||
<p>This method searches <var>string</var> for an occurrence of the regular expression pattern and returns an Array containing the results of the match, or <emu-val>null</emu-val> if <var>string</var> did not match.</p>
|
||
<p>It performs the following steps when called:</p>
|
||
<emu-alg><ol><li>Let <var>R</var> be the <emu-val>this</emu-val> value.</li><li>Perform ? <emu-xref aoid="RequireInternalSlot" id="_ref_12326"><a href="ordinary-and-exotic-objects-behaviours.html#sec-requireinternalslot">RequireInternalSlot</a></emu-xref>(<var>R</var>, <var class="field">[[RegExpMatcher]]</var>).</li><li>Let <var>S</var> be ? <emu-xref aoid="ToString" id="_ref_12327"><a href="abstract-operations.html#sec-tostring" class="e-user-code">ToString</a></emu-xref>(<var>string</var>).</li><li>Return ? <emu-xref aoid="RegExpBuiltinExec" id="_ref_12328"><a href="text-processing.html#sec-regexpbuiltinexec" class="e-user-code">RegExpBuiltinExec</a></emu-xref>(<var>R</var>, <var>S</var>).</li></ol></emu-alg>
|
||
</emu-clause>
|
||
|
||
<emu-clause id="sec-get-regexp.prototype.dotAll" type="built-in function">
|
||
<h1><span class="secnum">22.2.6.3</span> get RegExp.prototype.dotAll</h1>
|
||
<p><code>RegExp.prototype.dotAll</code> is an <emu-xref href="#sec-object-type" id="_ref_12329"><a href="ecmascript-data-types-and-values.html#sec-object-type">accessor property</a></emu-xref> whose set accessor function is <emu-val>undefined</emu-val>. Its get accessor function performs the following steps when called:</p>
|
||
<emu-alg><ol><li>Let <var>R</var> be the <emu-val>this</emu-val> value.</li><li>Let <var>cu</var> be the code unit 0x0073 (LATIN SMALL LETTER S).</li><li>Return ? <emu-xref aoid="RegExpHasFlag" id="_ref_12330"><a href="text-processing.html#sec-regexphasflag">RegExpHasFlag</a></emu-xref>(<var>R</var>, <var>cu</var>).</li></ol></emu-alg>
|
||
</emu-clause>
|
||
|
||
<emu-clause id="sec-get-regexp.prototype.flags" type="built-in function">
|
||
<h1><span class="secnum">22.2.6.4</span> get RegExp.prototype.flags</h1>
|
||
<p><code>RegExp.prototype.flags</code> is an <emu-xref href="#sec-object-type" id="_ref_12331"><a href="ecmascript-data-types-and-values.html#sec-object-type">accessor property</a></emu-xref> whose set accessor function is <emu-val>undefined</emu-val>. Its get accessor function performs the following steps when called:</p>
|
||
<emu-alg><ol><li>Let <var>R</var> be the <emu-val>this</emu-val> value.</li><li>If <var>R</var> <emu-xref href="#sec-object-type" id="_ref_12332"><a href="ecmascript-data-types-and-values.html#sec-object-type">is not an Object</a></emu-xref>, throw a <emu-val>TypeError</emu-val> exception.</li><li>Let <var>codeUnits</var> be a new empty <emu-xref href="#sec-list-and-record-specification-type" id="_ref_12333"><a href="ecmascript-data-types-and-values.html#sec-list-and-record-specification-type">List</a></emu-xref>.</li><li>Let <var>hasIndices</var> be <emu-xref aoid="ToBoolean" id="_ref_12334"><a href="abstract-operations.html#sec-toboolean">ToBoolean</a></emu-xref>(? <emu-xref aoid="Get" id="_ref_12335"><a href="abstract-operations.html#sec-get-o-p" class="e-user-code">Get</a></emu-xref>(<var>R</var>, <emu-val>"hasIndices"</emu-val>)).</li><li>If <var>hasIndices</var> is <emu-val>true</emu-val>, append the code unit 0x0064 (LATIN SMALL LETTER D) to <var>codeUnits</var>.</li><li>Let <var>global</var> be <emu-xref aoid="ToBoolean" id="_ref_12336"><a href="abstract-operations.html#sec-toboolean">ToBoolean</a></emu-xref>(? <emu-xref aoid="Get" id="_ref_12337"><a href="abstract-operations.html#sec-get-o-p" class="e-user-code">Get</a></emu-xref>(<var>R</var>, <emu-val>"global"</emu-val>)).</li><li>If <var>global</var> is <emu-val>true</emu-val>, append the code unit 0x0067 (LATIN SMALL LETTER G) to <var>codeUnits</var>.</li><li>Let <var>ignoreCase</var> be <emu-xref aoid="ToBoolean" id="_ref_12338"><a href="abstract-operations.html#sec-toboolean">ToBoolean</a></emu-xref>(? <emu-xref aoid="Get" id="_ref_12339"><a href="abstract-operations.html#sec-get-o-p" class="e-user-code">Get</a></emu-xref>(<var>R</var>, <emu-val>"ignoreCase"</emu-val>)).</li><li>If <var>ignoreCase</var> is <emu-val>true</emu-val>, append the code unit 0x0069 (LATIN SMALL LETTER I) to <var>codeUnits</var>.</li><li>Let <var>multiline</var> be <emu-xref aoid="ToBoolean" id="_ref_12340"><a href="abstract-operations.html#sec-toboolean">ToBoolean</a></emu-xref>(? <emu-xref aoid="Get" id="_ref_12341"><a href="abstract-operations.html#sec-get-o-p" class="e-user-code">Get</a></emu-xref>(<var>R</var>, <emu-val>"multiline"</emu-val>)).</li><li>If <var>multiline</var> is <emu-val>true</emu-val>, append the code unit 0x006D (LATIN SMALL LETTER M) to <var>codeUnits</var>.</li><li>Let <var>dotAll</var> be <emu-xref aoid="ToBoolean" id="_ref_12342"><a href="abstract-operations.html#sec-toboolean">ToBoolean</a></emu-xref>(? <emu-xref aoid="Get" id="_ref_12343"><a href="abstract-operations.html#sec-get-o-p" class="e-user-code">Get</a></emu-xref>(<var>R</var>, <emu-val>"dotAll"</emu-val>)).</li><li>If <var>dotAll</var> is <emu-val>true</emu-val>, append the code unit 0x0073 (LATIN SMALL LETTER S) to <var>codeUnits</var>.</li><li>Let <var>unicode</var> be <emu-xref aoid="ToBoolean" id="_ref_12344"><a href="abstract-operations.html#sec-toboolean">ToBoolean</a></emu-xref>(? <emu-xref aoid="Get" id="_ref_12345"><a href="abstract-operations.html#sec-get-o-p" class="e-user-code">Get</a></emu-xref>(<var>R</var>, <emu-val>"unicode"</emu-val>)).</li><li>If <var>unicode</var> is <emu-val>true</emu-val>, append the code unit 0x0075 (LATIN SMALL LETTER U) to <var>codeUnits</var>.</li><li>Let <var>unicodeSets</var> be <emu-xref aoid="ToBoolean" id="_ref_12346"><a href="abstract-operations.html#sec-toboolean">ToBoolean</a></emu-xref>(? <emu-xref aoid="Get" id="_ref_12347"><a href="abstract-operations.html#sec-get-o-p" class="e-user-code">Get</a></emu-xref>(<var>R</var>, <emu-val>"unicodeSets"</emu-val>)).</li><li>If <var>unicodeSets</var> is <emu-val>true</emu-val>, append the code unit 0x0076 (LATIN SMALL LETTER V) to <var>codeUnits</var>.</li><li>Let <var>sticky</var> be <emu-xref aoid="ToBoolean" id="_ref_12348"><a href="abstract-operations.html#sec-toboolean">ToBoolean</a></emu-xref>(? <emu-xref aoid="Get" id="_ref_12349"><a href="abstract-operations.html#sec-get-o-p" class="e-user-code">Get</a></emu-xref>(<var>R</var>, <emu-val>"sticky"</emu-val>)).</li><li>If <var>sticky</var> is <emu-val>true</emu-val>, append the code unit 0x0079 (LATIN SMALL LETTER Y) to <var>codeUnits</var>.</li><li>Return the String value whose code units are the elements of the <emu-xref href="#sec-list-and-record-specification-type" id="_ref_12350"><a href="ecmascript-data-types-and-values.html#sec-list-and-record-specification-type">List</a></emu-xref> <var>codeUnits</var>. If <var>codeUnits</var> has no elements, the empty String is returned.</li></ol></emu-alg>
|
||
|
||
<emu-clause id="sec-regexphasflag" type="abstract operation" aoid="RegExpHasFlag">
|
||
<h1><span class="secnum">22.2.6.4.1</span> RegExpHasFlag ( <var>R</var>, <var>codeUnit</var> )</h1>
|
||
<p>The abstract operation RegExpHasFlag takes arguments <var>R</var> (an <emu-xref href="#sec-ecmascript-language-types" id="_ref_12351"><a href="ecmascript-data-types-and-values.html#sec-ecmascript-language-types">ECMAScript language value</a></emu-xref>) and <var>codeUnit</var> (a code unit) and returns either a <emu-xref href="#sec-completion-record-specification-type" id="_ref_12352"><a href="ecmascript-data-types-and-values.html#sec-completion-record-specification-type">normal completion containing</a></emu-xref> either a Boolean or <emu-val>undefined</emu-val>, or a <emu-xref href="#sec-completion-record-specification-type" id="_ref_12353"><a href="ecmascript-data-types-and-values.html#sec-completion-record-specification-type">throw completion</a></emu-xref>. It performs the following steps when called:</p>
|
||
<emu-alg><ol><li>If <var>R</var> <emu-xref href="#sec-object-type" id="_ref_12354"><a href="ecmascript-data-types-and-values.html#sec-object-type">is not an Object</a></emu-xref>, throw a <emu-val>TypeError</emu-val> exception.</li><li>If <var>R</var> does not have an <var class="field">[[OriginalFlags]]</var> internal slot, then<ol><li>If <emu-xref aoid="SameValue" id="_ref_12355"><a href="abstract-operations.html#sec-samevalue">SameValue</a></emu-xref>(<var>R</var>, <emu-xref href="#sec-properties-of-the-regexp-prototype-object" id="_ref_12356"><a href="text-processing.html#sec-properties-of-the-regexp-prototype-object">%RegExp.prototype%</a></emu-xref>) is <emu-val>true</emu-val>, return <emu-val>undefined</emu-val>.</li><li>Throw a <emu-val>TypeError</emu-val> exception.</li></ol></li><li>Let <var>flags</var> be <var>R</var>.<var class="field">[[OriginalFlags]]</var>.</li><li>If <var>flags</var> contains <var>codeUnit</var>, return <emu-val>true</emu-val>.</li><li>Return <emu-val>false</emu-val>.</li></ol></emu-alg>
|
||
</emu-clause>
|
||
</emu-clause>
|
||
|
||
<emu-clause id="sec-get-regexp.prototype.global" type="built-in function">
|
||
<h1><span class="secnum">22.2.6.5</span> get RegExp.prototype.global</h1>
|
||
<p><code>RegExp.prototype.global</code> is an <emu-xref href="#sec-object-type" id="_ref_12357"><a href="ecmascript-data-types-and-values.html#sec-object-type">accessor property</a></emu-xref> whose set accessor function is <emu-val>undefined</emu-val>. Its get accessor function performs the following steps when called:</p>
|
||
<emu-alg><ol><li>Let <var>R</var> be the <emu-val>this</emu-val> value.</li><li>Let <var>cu</var> be the code unit 0x0067 (LATIN SMALL LETTER G).</li><li>Return ? <emu-xref aoid="RegExpHasFlag" id="_ref_12358"><a href="text-processing.html#sec-regexphasflag">RegExpHasFlag</a></emu-xref>(<var>R</var>, <var>cu</var>).</li></ol></emu-alg>
|
||
</emu-clause>
|
||
|
||
<emu-clause id="sec-get-regexp.prototype.hasIndices" type="built-in function">
|
||
<h1><span class="secnum">22.2.6.6</span> get RegExp.prototype.hasIndices</h1>
|
||
<p><code>RegExp.prototype.hasIndices</code> is an <emu-xref href="#sec-object-type" id="_ref_12359"><a href="ecmascript-data-types-and-values.html#sec-object-type">accessor property</a></emu-xref> whose set accessor function is <emu-val>undefined</emu-val>. Its get accessor function performs the following steps when called:</p>
|
||
<emu-alg><ol><li>Let <var>R</var> be the <emu-val>this</emu-val> value.</li><li>Let <var>cu</var> be the code unit 0x0064 (LATIN SMALL LETTER D).</li><li>Return ? <emu-xref aoid="RegExpHasFlag" id="_ref_12360"><a href="text-processing.html#sec-regexphasflag">RegExpHasFlag</a></emu-xref>(<var>R</var>, <var>cu</var>).</li></ol></emu-alg>
|
||
</emu-clause>
|
||
|
||
<emu-clause id="sec-get-regexp.prototype.ignorecase" type="built-in function">
|
||
<h1><span class="secnum">22.2.6.7</span> get RegExp.prototype.ignoreCase</h1>
|
||
<p><code>RegExp.prototype.ignoreCase</code> is an <emu-xref href="#sec-object-type" id="_ref_12361"><a href="ecmascript-data-types-and-values.html#sec-object-type">accessor property</a></emu-xref> whose set accessor function is <emu-val>undefined</emu-val>. Its get accessor function performs the following steps when called:</p>
|
||
<emu-alg><ol><li>Let <var>R</var> be the <emu-val>this</emu-val> value.</li><li>Let <var>cu</var> be the code unit 0x0069 (LATIN SMALL LETTER I).</li><li>Return ? <emu-xref aoid="RegExpHasFlag" id="_ref_12362"><a href="text-processing.html#sec-regexphasflag">RegExpHasFlag</a></emu-xref>(<var>R</var>, <var>cu</var>).</li></ol></emu-alg>
|
||
</emu-clause>
|
||
|
||
<emu-clause oldids="sec-regexp.prototype-@@match" id="sec-regexp.prototype-%symbol.match%" type="built-in function"><span id="sec-regexp.prototype-@@match"></span>
|
||
<h1><span class="secnum">22.2.6.8</span> RegExp.prototype [ %Symbol.match% ] ( <var>string</var> )</h1>
|
||
<p>This method performs the following steps when called:</p>
|
||
<emu-alg><ol><li>Let <var>rx</var> be the <emu-val>this</emu-val> value.</li><li>If <var>rx</var> <emu-xref href="#sec-object-type" id="_ref_12363"><a href="ecmascript-data-types-and-values.html#sec-object-type">is not an Object</a></emu-xref>, throw a <emu-val>TypeError</emu-val> exception.</li><li>Let <var>S</var> be ? <emu-xref aoid="ToString" id="_ref_12364"><a href="abstract-operations.html#sec-tostring" class="e-user-code">ToString</a></emu-xref>(<var>string</var>).</li><li>Let <var>flags</var> be ? <emu-xref aoid="ToString" id="_ref_12365"><a href="abstract-operations.html#sec-tostring" class="e-user-code">ToString</a></emu-xref>(? <emu-xref aoid="Get" id="_ref_12366"><a href="abstract-operations.html#sec-get-o-p" class="e-user-code">Get</a></emu-xref>(<var>rx</var>, <emu-val>"flags"</emu-val>)).</li><li>If <var>flags</var> does not contain <emu-val>"g"</emu-val>, return ? <emu-xref aoid="RegExpExec" id="_ref_12367"><a href="text-processing.html#sec-regexpexec" class="e-user-code">RegExpExec</a></emu-xref>(<var>rx</var>, <var>S</var>).</li><li>If <var>flags</var> contains <emu-val>"u"</emu-val> or <var>flags</var> contains <emu-val>"v"</emu-val>, let <var>fullUnicode</var> be <emu-val>true</emu-val>; else let <var>fullUnicode</var> be <emu-val>false</emu-val>.</li><li>Perform ? <emu-xref aoid="Set" id="_ref_12368"><a href="abstract-operations.html#sec-set-o-p-v-throw" class="e-user-code">Set</a></emu-xref>(<var>rx</var>, <emu-val>"lastIndex"</emu-val>, <emu-val>+0</emu-val><sub>𝔽</sub>, <emu-val>true</emu-val>).</li><li>Let <var>A</var> be ! <emu-xref aoid="ArrayCreate" id="_ref_12369"><a href="ordinary-and-exotic-objects-behaviours.html#sec-arraycreate">ArrayCreate</a></emu-xref>(0).</li><li>Let <var>n</var> be 0.</li><li>Repeat,<ol><li>Let <var>result</var> be ? <emu-xref aoid="RegExpExec" id="_ref_12370"><a href="text-processing.html#sec-regexpexec" class="e-user-code">RegExpExec</a></emu-xref>(<var>rx</var>, <var>S</var>).</li><li>If <var>result</var> is <emu-val>null</emu-val>, then<ol><li>If <var>n</var> = 0, return <emu-val>null</emu-val>.</li><li>Return <var>A</var>.</li></ol></li><li>Let <var>matchStr</var> be ? <emu-xref aoid="ToString" id="_ref_12371"><a href="abstract-operations.html#sec-tostring" class="e-user-code">ToString</a></emu-xref>(? <emu-xref aoid="Get" id="_ref_12372"><a href="abstract-operations.html#sec-get-o-p" class="e-user-code">Get</a></emu-xref>(<var>result</var>, <emu-val>"0"</emu-val>)).</li><li>Perform ! <emu-xref aoid="CreateDataPropertyOrThrow" id="_ref_12373"><a href="abstract-operations.html#sec-createdatapropertyorthrow">CreateDataPropertyOrThrow</a></emu-xref>(<var>A</var>, ! <emu-xref aoid="ToString" id="_ref_12374"><a href="abstract-operations.html#sec-tostring">ToString</a></emu-xref>(<emu-xref aoid="𝔽" id="_ref_12375"><a href="notational-conventions.html#%F0%9D%94%BD">𝔽</a></emu-xref>(<var>n</var>)), <var>matchStr</var>).</li><li>If <var>matchStr</var> is the empty String, then<ol><li>Let <var>thisIndex</var> be <emu-xref aoid="ℝ" id="_ref_12376"><a href="notational-conventions.html#%E2%84%9D">ℝ</a></emu-xref>(? <emu-xref aoid="ToLength" id="_ref_12377"><a href="abstract-operations.html#sec-tolength" class="e-user-code">ToLength</a></emu-xref>(? <emu-xref aoid="Get" id="_ref_12378"><a href="abstract-operations.html#sec-get-o-p" class="e-user-code">Get</a></emu-xref>(<var>rx</var>, <emu-val>"lastIndex"</emu-val>))).</li><li>Let <var>nextIndex</var> be <emu-xref aoid="AdvanceStringIndex" id="_ref_12379"><a href="text-processing.html#sec-advancestringindex">AdvanceStringIndex</a></emu-xref>(<var>S</var>, <var>thisIndex</var>, <var>fullUnicode</var>).</li><li>Perform ? <emu-xref aoid="Set" id="_ref_12380"><a href="abstract-operations.html#sec-set-o-p-v-throw" class="e-user-code">Set</a></emu-xref>(<var>rx</var>, <emu-val>"lastIndex"</emu-val>, <emu-xref aoid="𝔽" id="_ref_12381"><a href="notational-conventions.html#%F0%9D%94%BD">𝔽</a></emu-xref>(<var>nextIndex</var>), <emu-val>true</emu-val>).</li></ol></li><li>Set <var>n</var> to <var>n</var> + 1.</li></ol></li></ol></emu-alg>
|
||
<p>The value of the <emu-val>"name"</emu-val> property of this method is <emu-val>"[Symbol.match]"</emu-val>.</p>
|
||
<emu-note><span class="note">Note</span><div class="note-contents">
|
||
<p>The <emu-xref href="#sec-well-known-symbols" id="_ref_12382"><a href="ecmascript-data-types-and-values.html#sec-well-known-symbols">%Symbol.match%</a></emu-xref> property is used by the <emu-xref aoid="IsRegExp" id="_ref_12383"><a href="abstract-operations.html#sec-isregexp">IsRegExp</a></emu-xref> abstract operation to identify objects that have the basic behaviour of regular expressions. The absence of a <emu-xref href="#sec-well-known-symbols" id="_ref_12384"><a href="ecmascript-data-types-and-values.html#sec-well-known-symbols">%Symbol.match%</a></emu-xref> property or the existence of such a property whose value does not Boolean coerce to <emu-val>true</emu-val> indicates that the object is not intended to be used as a regular expression object.</p>
|
||
</div></emu-note>
|
||
</emu-clause>
|
||
|
||
<emu-clause oldids="sec-regexp-prototype-matchall" id="sec-regexp-prototype-%symbol.matchall%" type="built-in function"><span id="sec-regexp-prototype-matchall"></span>
|
||
<h1><span class="secnum">22.2.6.9</span> RegExp.prototype [ %Symbol.matchAll% ] ( <var>string</var> )</h1>
|
||
<p>This method performs the following steps when called:</p>
|
||
<emu-alg><ol><li>Let <var>R</var> be the <emu-val>this</emu-val> value.</li><li>If <var>R</var> <emu-xref href="#sec-object-type" id="_ref_12385"><a href="ecmascript-data-types-and-values.html#sec-object-type">is not an Object</a></emu-xref>, throw a <emu-val>TypeError</emu-val> exception.</li><li>Let <var>S</var> be ? <emu-xref aoid="ToString" id="_ref_12386"><a href="abstract-operations.html#sec-tostring" class="e-user-code">ToString</a></emu-xref>(<var>string</var>).</li><li>Let <var>C</var> be ? <emu-xref aoid="SpeciesConstructor" id="_ref_12387"><a href="abstract-operations.html#sec-speciesconstructor" class="e-user-code">SpeciesConstructor</a></emu-xref>(<var>R</var>, <emu-xref href="#sec-regexp-constructor" id="_ref_12388"><a href="text-processing.html#sec-regexp-constructor">%RegExp%</a></emu-xref>).</li><li>Let <var>flags</var> be ? <emu-xref aoid="ToString" id="_ref_12389"><a href="abstract-operations.html#sec-tostring" class="e-user-code">ToString</a></emu-xref>(? <emu-xref aoid="Get" id="_ref_12390"><a href="abstract-operations.html#sec-get-o-p" class="e-user-code">Get</a></emu-xref>(<var>R</var>, <emu-val>"flags"</emu-val>)).</li><li>Let <var>matcher</var> be ? <emu-xref aoid="Construct" id="_ref_12391"><a href="abstract-operations.html#sec-construct" class="e-user-code">Construct</a></emu-xref>(<var>C</var>, « <var>R</var>, <var>flags</var> »).</li><li>Let <var>lastIndex</var> be ? <emu-xref aoid="ToLength" id="_ref_12392"><a href="abstract-operations.html#sec-tolength" class="e-user-code">ToLength</a></emu-xref>(? <emu-xref aoid="Get" id="_ref_12393"><a href="abstract-operations.html#sec-get-o-p" class="e-user-code">Get</a></emu-xref>(<var>R</var>, <emu-val>"lastIndex"</emu-val>)).</li><li>Perform ? <emu-xref aoid="Set" id="_ref_12394"><a href="abstract-operations.html#sec-set-o-p-v-throw" class="e-user-code">Set</a></emu-xref>(<var>matcher</var>, <emu-val>"lastIndex"</emu-val>, <var>lastIndex</var>, <emu-val>true</emu-val>).</li><li>If <var>flags</var> contains <emu-val>"g"</emu-val>, let <var>global</var> be <emu-val>true</emu-val>.</li><li>Else, let <var>global</var> be <emu-val>false</emu-val>.</li><li>If <var>flags</var> contains <emu-val>"u"</emu-val> or <var>flags</var> contains <emu-val>"v"</emu-val>, let <var>fullUnicode</var> be <emu-val>true</emu-val>.</li><li>Else, let <var>fullUnicode</var> be <emu-val>false</emu-val>.</li><li>Return <emu-xref aoid="CreateRegExpStringIterator" id="_ref_12395"><a href="text-processing.html#sec-createregexpstringiterator">CreateRegExpStringIterator</a></emu-xref>(<var>matcher</var>, <var>S</var>, <var>global</var>, <var>fullUnicode</var>).</li></ol></emu-alg>
|
||
<p>The value of the <emu-val>"name"</emu-val> property of this method is <emu-val>"[Symbol.matchAll]"</emu-val>.</p>
|
||
</emu-clause>
|
||
|
||
<emu-clause id="sec-get-regexp.prototype.multiline" type="built-in function">
|
||
<h1><span class="secnum">22.2.6.10</span> get RegExp.prototype.multiline</h1>
|
||
<p><code>RegExp.prototype.multiline</code> is an <emu-xref href="#sec-object-type" id="_ref_12396"><a href="ecmascript-data-types-and-values.html#sec-object-type">accessor property</a></emu-xref> whose set accessor function is <emu-val>undefined</emu-val>. Its get accessor function performs the following steps when called:</p>
|
||
<emu-alg><ol><li>Let <var>R</var> be the <emu-val>this</emu-val> value.</li><li>Let <var>cu</var> be the code unit 0x006D (LATIN SMALL LETTER M).</li><li>Return ? <emu-xref aoid="RegExpHasFlag" id="_ref_12397"><a href="text-processing.html#sec-regexphasflag">RegExpHasFlag</a></emu-xref>(<var>R</var>, <var>cu</var>).</li></ol></emu-alg>
|
||
</emu-clause>
|
||
|
||
<emu-clause oldids="sec-regexp.prototype-@@replace" id="sec-regexp.prototype-%symbol.replace%" type="built-in function"><span id="sec-regexp.prototype-@@replace"></span>
|
||
<h1><span class="secnum">22.2.6.11</span> RegExp.prototype [ %Symbol.replace% ] ( <var>string</var>, <var>replaceValue</var> )</h1>
|
||
<p>This method performs the following steps when called:</p>
|
||
<emu-alg><ol><li>Let <var>rx</var> be the <emu-val>this</emu-val> value.</li><li>If <var>rx</var> <emu-xref href="#sec-object-type" id="_ref_12398"><a href="ecmascript-data-types-and-values.html#sec-object-type">is not an Object</a></emu-xref>, throw a <emu-val>TypeError</emu-val> exception.</li><li>Let <var>S</var> be ? <emu-xref aoid="ToString" id="_ref_12399"><a href="abstract-operations.html#sec-tostring" class="e-user-code">ToString</a></emu-xref>(<var>string</var>).</li><li>Let <var>lengthS</var> be the length of <var>S</var>.</li><li>Let <var>functionalReplace</var> be <emu-xref aoid="IsCallable" id="_ref_12400"><a href="abstract-operations.html#sec-iscallable">IsCallable</a></emu-xref>(<var>replaceValue</var>).</li><li>If <var>functionalReplace</var> is <emu-val>false</emu-val>, then<ol><li>Set <var>replaceValue</var> to ? <emu-xref aoid="ToString" id="_ref_12401"><a href="abstract-operations.html#sec-tostring" class="e-user-code">ToString</a></emu-xref>(<var>replaceValue</var>).</li></ol></li><li>Let <var>flags</var> be ? <emu-xref aoid="ToString" id="_ref_12402"><a href="abstract-operations.html#sec-tostring" class="e-user-code">ToString</a></emu-xref>(? <emu-xref aoid="Get" id="_ref_12403"><a href="abstract-operations.html#sec-get-o-p" class="e-user-code">Get</a></emu-xref>(<var>rx</var>, <emu-val>"flags"</emu-val>)).</li><li>If <var>flags</var> contains <emu-val>"g"</emu-val>, let <var>global</var> be <emu-val>true</emu-val>; else let <var>global</var> be <emu-val>false</emu-val>.</li><li>If <var>global</var> is <emu-val>true</emu-val>, then<ol><li>Perform ? <emu-xref aoid="Set" id="_ref_12404"><a href="abstract-operations.html#sec-set-o-p-v-throw" class="e-user-code">Set</a></emu-xref>(<var>rx</var>, <emu-val>"lastIndex"</emu-val>, <emu-val>+0</emu-val><sub>𝔽</sub>, <emu-val>true</emu-val>).</li></ol></li><li>Let <var>results</var> be a new empty <emu-xref href="#sec-list-and-record-specification-type" id="_ref_12405"><a href="ecmascript-data-types-and-values.html#sec-list-and-record-specification-type">List</a></emu-xref>.</li><li>Let <var>done</var> be <emu-val>false</emu-val>.</li><li>Repeat, while <var>done</var> is <emu-val>false</emu-val>,<ol><li>Let <var>result</var> be ? <emu-xref aoid="RegExpExec" id="_ref_12406"><a href="text-processing.html#sec-regexpexec" class="e-user-code">RegExpExec</a></emu-xref>(<var>rx</var>, <var>S</var>).</li><li>If <var>result</var> is <emu-val>null</emu-val>, then<ol><li>Set <var>done</var> to <emu-val>true</emu-val>.</li></ol></li><li>Else,<ol><li>Append <var>result</var> to <var>results</var>.</li><li>If <var>global</var> is <emu-val>false</emu-val>, then<ol><li>Set <var>done</var> to <emu-val>true</emu-val>.</li></ol></li><li>Else,<ol><li>Let <var>matchStr</var> be ? <emu-xref aoid="ToString" id="_ref_12407"><a href="abstract-operations.html#sec-tostring" class="e-user-code">ToString</a></emu-xref>(? <emu-xref aoid="Get" id="_ref_12408"><a href="abstract-operations.html#sec-get-o-p" class="e-user-code">Get</a></emu-xref>(<var>result</var>, <emu-val>"0"</emu-val>)).</li><li>If <var>matchStr</var> is the empty String, then<ol><li>Let <var>thisIndex</var> be <emu-xref aoid="ℝ" id="_ref_12409"><a href="notational-conventions.html#%E2%84%9D">ℝ</a></emu-xref>(? <emu-xref aoid="ToLength" id="_ref_12410"><a href="abstract-operations.html#sec-tolength" class="e-user-code">ToLength</a></emu-xref>(? <emu-xref aoid="Get" id="_ref_12411"><a href="abstract-operations.html#sec-get-o-p" class="e-user-code">Get</a></emu-xref>(<var>rx</var>, <emu-val>"lastIndex"</emu-val>))).</li><li>If <var>flags</var> contains <emu-val>"u"</emu-val> or <var>flags</var> contains <emu-val>"v"</emu-val>, let <var>fullUnicode</var> be <emu-val>true</emu-val>; else let <var>fullUnicode</var> be <emu-val>false</emu-val>.</li><li>Let <var>nextIndex</var> be <emu-xref aoid="AdvanceStringIndex" id="_ref_12412"><a href="text-processing.html#sec-advancestringindex">AdvanceStringIndex</a></emu-xref>(<var>S</var>, <var>thisIndex</var>, <var>fullUnicode</var>).</li><li>Perform ? <emu-xref aoid="Set" id="_ref_12413"><a href="abstract-operations.html#sec-set-o-p-v-throw" class="e-user-code">Set</a></emu-xref>(<var>rx</var>, <emu-val>"lastIndex"</emu-val>, <emu-xref aoid="𝔽" id="_ref_12414"><a href="notational-conventions.html#%F0%9D%94%BD">𝔽</a></emu-xref>(<var>nextIndex</var>), <emu-val>true</emu-val>).</li></ol></li></ol></li></ol></li></ol></li><li>Let <var>accumulatedResult</var> be the empty String.</li><li>Let <var>nextSourcePosition</var> be 0.</li><li>For each element <var>result</var> of <var>results</var>, do<ol><li>Let <var>resultLength</var> be ? <emu-xref aoid="LengthOfArrayLike" id="_ref_12415"><a href="abstract-operations.html#sec-lengthofarraylike" class="e-user-code">LengthOfArrayLike</a></emu-xref>(<var>result</var>).</li><li>Let <var>nCaptures</var> be <emu-xref aoid="max" id="_ref_12416"><a href="notational-conventions.html#eqn-max">max</a></emu-xref>(<var>resultLength</var> - 1, 0).</li><li>Let <var>matched</var> be ? <emu-xref aoid="ToString" id="_ref_12417"><a href="abstract-operations.html#sec-tostring" class="e-user-code">ToString</a></emu-xref>(? <emu-xref aoid="Get" id="_ref_12418"><a href="abstract-operations.html#sec-get-o-p" class="e-user-code">Get</a></emu-xref>(<var>result</var>, <emu-val>"0"</emu-val>)).</li><li>Let <var>matchLength</var> be the length of <var>matched</var>.</li><li>Let <var>position</var> be ? <emu-xref aoid="ToIntegerOrInfinity" id="_ref_12419"><a href="abstract-operations.html#sec-tointegerorinfinity" class="e-user-code">ToIntegerOrInfinity</a></emu-xref>(? <emu-xref aoid="Get" id="_ref_12420"><a href="abstract-operations.html#sec-get-o-p" class="e-user-code">Get</a></emu-xref>(<var>result</var>, <emu-val>"index"</emu-val>)).</li><li>Set <var>position</var> to the result of <emu-xref href="#clamping" id="_ref_12421"><a href="notational-conventions.html#clamping">clamping</a></emu-xref> <var>position</var> between 0 and <var>lengthS</var>.</li><li>Let <var>captures</var> be a new empty <emu-xref href="#sec-list-and-record-specification-type" id="_ref_12422"><a href="ecmascript-data-types-and-values.html#sec-list-and-record-specification-type">List</a></emu-xref>.</li><li>Let <var>n</var> be 1.</li><li>Repeat, while <var>n</var> ≤ <var>nCaptures</var>,<ol><li>Let <var>capN</var> be ? <emu-xref aoid="Get" id="_ref_12423"><a href="abstract-operations.html#sec-get-o-p" class="e-user-code">Get</a></emu-xref>(<var>result</var>, ! <emu-xref aoid="ToString" id="_ref_12424"><a href="abstract-operations.html#sec-tostring">ToString</a></emu-xref>(<emu-xref aoid="𝔽" id="_ref_12425"><a href="notational-conventions.html#%F0%9D%94%BD">𝔽</a></emu-xref>(<var>n</var>))).</li><li>If <var>capN</var> is not <emu-val>undefined</emu-val>, then<ol><li>Set <var>capN</var> to ? <emu-xref aoid="ToString" id="_ref_12426"><a href="abstract-operations.html#sec-tostring" class="e-user-code">ToString</a></emu-xref>(<var>capN</var>).</li></ol></li><li>Append <var>capN</var> to <var>captures</var>.</li><li>NOTE: When <var>n</var> = 1, the preceding step puts the first element into <var>captures</var> (at index 0). More generally, the <var>n</var><sup>th</sup> capture (the characters captured by the <var>n</var><sup>th</sup> set of capturing parentheses) is at <var>captures</var>[<var>n</var> - 1].</li><li>Set <var>n</var> to <var>n</var> + 1.</li></ol></li><li>Let <var>namedCaptures</var> be ? <emu-xref aoid="Get" id="_ref_12427"><a href="abstract-operations.html#sec-get-o-p" class="e-user-code">Get</a></emu-xref>(<var>result</var>, <emu-val>"groups"</emu-val>).</li><li>If <var>functionalReplace</var> is <emu-val>true</emu-val>, then<ol><li>Let <var>replacerArgs</var> be the <emu-xref href="#list-concatenation" id="_ref_12428"><a href="ecmascript-data-types-and-values.html#list-concatenation">list-concatenation</a></emu-xref> of « <var>matched</var> », <var>captures</var>, and « <emu-xref aoid="𝔽" id="_ref_12429"><a href="notational-conventions.html#%F0%9D%94%BD">𝔽</a></emu-xref>(<var>position</var>), <var>S</var> ».</li><li>If <var>namedCaptures</var> is not <emu-val>undefined</emu-val>, then<ol><li>Append <var>namedCaptures</var> to <var>replacerArgs</var>.</li></ol></li><li>Let <var>replacementValue</var> be ? <emu-xref aoid="Call" id="_ref_12430"><a href="abstract-operations.html#sec-call" class="e-user-code">Call</a></emu-xref>(<var>replaceValue</var>, <emu-val>undefined</emu-val>, <var>replacerArgs</var>).</li><li>Let <var>replacementString</var> be ? <emu-xref aoid="ToString" id="_ref_12431"><a href="abstract-operations.html#sec-tostring" class="e-user-code">ToString</a></emu-xref>(<var>replacementValue</var>).</li></ol></li><li>Else,<ol><li>If <var>namedCaptures</var> is not <emu-val>undefined</emu-val>, then<ol><li>Set <var>namedCaptures</var> to ? <emu-xref aoid="ToObject" id="_ref_12432"><a href="abstract-operations.html#sec-toobject">ToObject</a></emu-xref>(<var>namedCaptures</var>).</li></ol></li><li>Let <var>replacementString</var> be ? <emu-xref aoid="GetSubstitution" id="_ref_12433"><a href="text-processing.html#sec-getsubstitution" class="e-user-code">GetSubstitution</a></emu-xref>(<var>matched</var>, <var>S</var>, <var>position</var>, <var>captures</var>, <var>namedCaptures</var>, <var>replaceValue</var>).</li></ol></li><li>If <var>position</var> ≥ <var>nextSourcePosition</var>, then<ol><li>NOTE: <var>position</var> should not normally move backwards. If it does, it is an indication of an ill-behaving RegExp subclass or use of an access triggered side-effect to change the global flag or other characteristics of <var>rx</var>. In such cases, the corresponding substitution is ignored.</li><li>Set <var>accumulatedResult</var> to the <emu-xref href="#string-concatenation" id="_ref_12434"><a href="ecmascript-data-types-and-values.html#string-concatenation">string-concatenation</a></emu-xref> of <var>accumulatedResult</var>, the <emu-xref href="#substring" id="_ref_12435"><a href="ecmascript-data-types-and-values.html#substring">substring</a></emu-xref> of <var>S</var> from <var>nextSourcePosition</var> to <var>position</var>, and <var>replacementString</var>.</li><li>Set <var>nextSourcePosition</var> to <var>position</var> + <var>matchLength</var>.</li></ol></li></ol></li><li>If <var>nextSourcePosition</var> ≥ <var>lengthS</var>, return <var>accumulatedResult</var>.</li><li>Return the <emu-xref href="#string-concatenation" id="_ref_12436"><a href="ecmascript-data-types-and-values.html#string-concatenation">string-concatenation</a></emu-xref> of <var>accumulatedResult</var> and the <emu-xref href="#substring" id="_ref_12437"><a href="ecmascript-data-types-and-values.html#substring">substring</a></emu-xref> of <var>S</var> from <var>nextSourcePosition</var>.</li></ol></emu-alg>
|
||
<p>The value of the <emu-val>"name"</emu-val> property of this method is <emu-val>"[Symbol.replace]"</emu-val>.</p>
|
||
</emu-clause>
|
||
|
||
<emu-clause oldids="sec-regexp.prototype-@@search" id="sec-regexp.prototype-%symbol.search%" type="built-in function"><span id="sec-regexp.prototype-@@search"></span>
|
||
<h1><span class="secnum">22.2.6.12</span> RegExp.prototype [ %Symbol.search% ] ( <var>string</var> )</h1>
|
||
<p>This method performs the following steps when called:</p>
|
||
<emu-alg><ol><li>Let <var>rx</var> be the <emu-val>this</emu-val> value.</li><li>If <var>rx</var> <emu-xref href="#sec-object-type" id="_ref_12438"><a href="ecmascript-data-types-and-values.html#sec-object-type">is not an Object</a></emu-xref>, throw a <emu-val>TypeError</emu-val> exception.</li><li>Let <var>S</var> be ? <emu-xref aoid="ToString" id="_ref_12439"><a href="abstract-operations.html#sec-tostring" class="e-user-code">ToString</a></emu-xref>(<var>string</var>).</li><li>Let <var>previousLastIndex</var> be ? <emu-xref aoid="Get" id="_ref_12440"><a href="abstract-operations.html#sec-get-o-p" class="e-user-code">Get</a></emu-xref>(<var>rx</var>, <emu-val>"lastIndex"</emu-val>).</li><li>If <var>previousLastIndex</var> is not <emu-val>+0</emu-val><sub>𝔽</sub>, then<ol><li>Perform ? <emu-xref aoid="Set" id="_ref_12441"><a href="abstract-operations.html#sec-set-o-p-v-throw" class="e-user-code">Set</a></emu-xref>(<var>rx</var>, <emu-val>"lastIndex"</emu-val>, <emu-val>+0</emu-val><sub>𝔽</sub>, <emu-val>true</emu-val>).</li></ol></li><li>Let <var>result</var> be ? <emu-xref aoid="RegExpExec" id="_ref_12442"><a href="text-processing.html#sec-regexpexec" class="e-user-code">RegExpExec</a></emu-xref>(<var>rx</var>, <var>S</var>).</li><li>Let <var>currentLastIndex</var> be ? <emu-xref aoid="Get" id="_ref_12443"><a href="abstract-operations.html#sec-get-o-p" class="e-user-code">Get</a></emu-xref>(<var>rx</var>, <emu-val>"lastIndex"</emu-val>).</li><li>If <emu-xref aoid="SameValue" id="_ref_12444"><a href="abstract-operations.html#sec-samevalue">SameValue</a></emu-xref>(<var>currentLastIndex</var>, <var>previousLastIndex</var>) is <emu-val>false</emu-val>, then<ol><li>Perform ? <emu-xref aoid="Set" id="_ref_12445"><a href="abstract-operations.html#sec-set-o-p-v-throw" class="e-user-code">Set</a></emu-xref>(<var>rx</var>, <emu-val>"lastIndex"</emu-val>, <var>previousLastIndex</var>, <emu-val>true</emu-val>).</li></ol></li><li>If <var>result</var> is <emu-val>null</emu-val>, return <emu-val>-1</emu-val><sub>𝔽</sub>.</li><li>Return ? <emu-xref aoid="Get" id="_ref_12446"><a href="abstract-operations.html#sec-get-o-p" class="e-user-code">Get</a></emu-xref>(<var>result</var>, <emu-val>"index"</emu-val>).</li></ol></emu-alg>
|
||
<p>The value of the <emu-val>"name"</emu-val> property of this method is <emu-val>"[Symbol.search]"</emu-val>.</p>
|
||
<emu-note><span class="note">Note</span><div class="note-contents">
|
||
<p>The <emu-val>"lastIndex"</emu-val> and <emu-val>"global"</emu-val> properties of this RegExp object are ignored when performing the search. The <emu-val>"lastIndex"</emu-val> property is left unchanged.</p>
|
||
</div></emu-note>
|
||
</emu-clause>
|
||
|
||
<emu-clause id="sec-get-regexp.prototype.source" type="built-in function">
|
||
<h1><span class="secnum">22.2.6.13</span> get RegExp.prototype.source</h1>
|
||
<p><code>RegExp.prototype.source</code> is an <emu-xref href="#sec-object-type" id="_ref_12447"><a href="ecmascript-data-types-and-values.html#sec-object-type">accessor property</a></emu-xref> whose set accessor function is <emu-val>undefined</emu-val>. Its get accessor function performs the following steps when called:</p>
|
||
<emu-alg><ol><li>Let <var>R</var> be the <emu-val>this</emu-val> value.</li><li>If <var>R</var> <emu-xref href="#sec-object-type" id="_ref_12448"><a href="ecmascript-data-types-and-values.html#sec-object-type">is not an Object</a></emu-xref>, throw a <emu-val>TypeError</emu-val> exception.</li><li>If <var>R</var> does not have an <var class="field">[[OriginalSource]]</var> internal slot, then<ol><li>If <emu-xref aoid="SameValue" id="_ref_12449"><a href="abstract-operations.html#sec-samevalue">SameValue</a></emu-xref>(<var>R</var>, <emu-xref href="#sec-properties-of-the-regexp-prototype-object" id="_ref_12450"><a href="text-processing.html#sec-properties-of-the-regexp-prototype-object">%RegExp.prototype%</a></emu-xref>) is <emu-val>true</emu-val>, return <emu-val>"(?:)"</emu-val>.</li><li>Throw a <emu-val>TypeError</emu-val> exception.</li></ol></li><li><emu-xref href="#assert" id="_ref_12451"><a href="notational-conventions.html#assert">Assert</a></emu-xref>: <var>R</var> has an <var class="field">[[OriginalFlags]]</var> internal slot.</li><li>Let <var>src</var> be <var>R</var>.<var class="field">[[OriginalSource]]</var>.</li><li>Let <var>flags</var> be <var>R</var>.<var class="field">[[OriginalFlags]]</var>.</li><li>Return <emu-xref aoid="EscapeRegExpPattern" id="_ref_12452"><a href="text-processing.html#sec-escaperegexppattern">EscapeRegExpPattern</a></emu-xref>(<var>src</var>, <var>flags</var>).</li></ol></emu-alg>
|
||
|
||
<emu-clause id="sec-escaperegexppattern" type="abstract operation" aoid="EscapeRegExpPattern">
|
||
<h1><span class="secnum">22.2.6.13.1</span> EscapeRegExpPattern ( <var>P</var>, <var>F</var> )</h1>
|
||
<p>The abstract operation EscapeRegExpPattern takes arguments <var>P</var> (a String) and <var>F</var> (a String) and returns a String. It performs the following steps when called:</p>
|
||
<emu-alg><ol><li>If <var>F</var> contains <emu-val>"v"</emu-val>, then<ol><li>Let <var>patternSymbol</var> be <emu-nt params="+UnicodeMode, +UnicodeSetsMode" id="_ref_24537"><a href="text-processing.html#prod-Pattern">Pattern</a><emu-mods><emu-params>[+UnicodeMode, +UnicodeSetsMode]</emu-params></emu-mods></emu-nt>.</li></ol></li><li>Else if <var>F</var> contains <emu-val>"u"</emu-val>, then<ol><li>Let <var>patternSymbol</var> be <emu-nt params="+UnicodeMode, ~UnicodeSetsMode" id="_ref_24538"><a href="text-processing.html#prod-Pattern">Pattern</a><emu-mods><emu-params>[+UnicodeMode, ~UnicodeSetsMode]</emu-params></emu-mods></emu-nt>.</li></ol></li><li>Else,<ol><li>Let <var>patternSymbol</var> be <emu-nt params="~UnicodeMode, ~UnicodeSetsMode" id="_ref_24539"><a href="text-processing.html#prod-Pattern">Pattern</a><emu-mods><emu-params>[~UnicodeMode, ~UnicodeSetsMode]</emu-params></emu-mods></emu-nt>.</li></ol></li><li>Let <var>S</var> be a String in the form of a <var>patternSymbol</var> equivalent to <var>P</var> interpreted as UTF-16 encoded Unicode code points (<emu-xref href="#sec-ecmascript-language-types-string-type" id="_ref_711"><a href="ecmascript-data-types-and-values.html#sec-ecmascript-language-types-string-type">6.1.4</a></emu-xref>), in which certain code points are escaped as described below. <var>S</var> may or may not differ from <var>P</var>; however, the <emu-xref href="#sec-abstract-closure" id="_ref_12453"><a href="ecmascript-data-types-and-values.html#sec-abstract-closure">Abstract Closure</a></emu-xref> that would result from evaluating <var>S</var> as a <var>patternSymbol</var> must behave identically to the <emu-xref href="#sec-abstract-closure" id="_ref_12454"><a href="ecmascript-data-types-and-values.html#sec-abstract-closure">Abstract Closure</a></emu-xref> given by the constructed object's <var class="field">[[RegExpMatcher]]</var> internal slot. Multiple calls to this abstract operation using the same values for <var>P</var> and <var>F</var> must produce identical results.</li><li>The code points <code>/</code> or any <emu-nt id="_ref_24540"><a href="ecmascript-language-lexical-grammar.html#prod-LineTerminator">LineTerminator</a></emu-nt> occurring in the pattern shall be escaped in <var>S</var> as necessary to ensure that the <emu-xref href="#string-concatenation" id="_ref_12455"><a href="ecmascript-data-types-and-values.html#string-concatenation">string-concatenation</a></emu-xref> of <emu-val>"/"</emu-val>, <var>S</var>, <emu-val>"/"</emu-val>, and <var>F</var> can be parsed (in an appropriate lexical context) as a <emu-nt id="_ref_24541"><a href="ecmascript-language-lexical-grammar.html#prod-RegularExpressionLiteral">RegularExpressionLiteral</a></emu-nt> that behaves identically to the constructed regular expression. For example, if <var>P</var> is <emu-val>"/"</emu-val>, then <var>S</var> could be <emu-val>"\/"</emu-val> or <emu-val>"\u002F"</emu-val>, among other possibilities, but not <emu-val>"/"</emu-val>, because <code>///</code> followed by <var>F</var> would be parsed as a <emu-nt id="_ref_24542"><a href="ecmascript-language-lexical-grammar.html#prod-SingleLineComment">SingleLineComment</a></emu-nt> rather than a <emu-nt id="_ref_24543"><a href="ecmascript-language-lexical-grammar.html#prod-RegularExpressionLiteral">RegularExpressionLiteral</a></emu-nt>. If <var>P</var> is the empty String, this specification can be met by letting <var>S</var> be <emu-val>"(?:)"</emu-val>.</li><li>Return <var>S</var>.</li></ol></emu-alg>
|
||
|
||
<emu-note><span class="note">Note</span><div class="note-contents">
|
||
<p>Despite having similar names, <code>RegExp.escape</code> and EscapeRegExpPattern do not perform similar actions. The former escapes a string for representation inside a pattern, while this function escapes a pattern for representation as a string.</p>
|
||
</div></emu-note>
|
||
</emu-clause>
|
||
</emu-clause>
|
||
|
||
<emu-clause oldids="sec-regexp.prototype-@@split" id="sec-regexp.prototype-%symbol.split%" type="built-in function"><span id="sec-regexp.prototype-@@split"></span>
|
||
<h1><span class="secnum">22.2.6.14</span> RegExp.prototype [ %Symbol.split% ] ( <var>string</var>, <var>limit</var> )</h1>
|
||
<emu-note><span class="note">Note 1</span><div class="note-contents">
|
||
<p>This method returns an Array into which substrings of the result of converting <var>string</var> to a String have been stored. The substrings are determined by searching from left to right for matches of the <emu-val>this</emu-val> value regular expression; these occurrences are not part of any String in the returned array, but serve to divide up the String value.</p>
|
||
<p>The <emu-val>this</emu-val> value may be an empty regular expression or a regular expression that can match an empty String. In this case, the regular expression does not match the empty <emu-not-ref>substring</emu-not-ref> at the beginning or end of the input String, nor does it match the empty <emu-not-ref>substring</emu-not-ref> at the end of the previous separator match. (For example, if the regular expression matches the empty String, the String is split up into individual code unit elements; the length of the result array equals the length of the String, and each <emu-not-ref>substring</emu-not-ref> contains one code unit.) Only the first match at a given index of the String is considered, even if backtracking could yield a non-empty <emu-not-ref>substring</emu-not-ref> match at that index. (For example, <code>/a*?/[Symbol.split]("ab")</code> evaluates to the array <code>["a", "b"]</code>, while <code>/a*/[Symbol.split]("ab")</code> evaluates to the array <code>["","b"]</code>.)</p>
|
||
<p>If <var>string</var> is (or converts to) the empty String, the result depends on whether the regular expression can match the empty String. If it can, the result array contains no elements. Otherwise, the result array contains one element, which is the empty String.</p>
|
||
<p>If the regular expression contains capturing parentheses, then each time <var>separator</var> is matched the results (including any <emu-val>undefined</emu-val> results) of the capturing parentheses are spliced into the output array. For example,</p>
|
||
<pre><code class="javascript hljs">/<(\/)?([^<span class="language-xml"><span class="hljs-tag"><></span>]+)>/[Symbol.split]("A<span class="hljs-tag"><<span class="hljs-name">B</span>></span>bold<span class="hljs-tag"></<span class="hljs-name">B</span>></span>and<span class="hljs-tag"><<span class="hljs-name">CODE</span>></span>coded<span class="hljs-tag"></<span class="hljs-name">CODE</span>></span>")</span></code></pre>
|
||
<p>evaluates to the array</p>
|
||
<pre><code class="javascript hljs">[<span class="hljs-string">"A"</span>, <span class="hljs-literal">undefined</span>, <span class="hljs-string">"B"</span>, <span class="hljs-string">"bold"</span>, <span class="hljs-string">"/"</span>, <span class="hljs-string">"B"</span>, <span class="hljs-string">"and"</span>, <span class="hljs-literal">undefined</span>, <span class="hljs-string">"CODE"</span>, <span class="hljs-string">"coded"</span>, <span class="hljs-string">"/"</span>, <span class="hljs-string">"CODE"</span>, <span class="hljs-string">""</span>]</code></pre>
|
||
<p>If <var>limit</var> is not <emu-val>undefined</emu-val>, then the output array is truncated so that it contains no more than <var>limit</var> elements.</p>
|
||
</div></emu-note>
|
||
<p>This method performs the following steps when called:</p>
|
||
<emu-alg><ol><li>Let <var>rx</var> be the <emu-val>this</emu-val> value.</li><li>If <var>rx</var> <emu-xref href="#sec-object-type" id="_ref_12456"><a href="ecmascript-data-types-and-values.html#sec-object-type">is not an Object</a></emu-xref>, throw a <emu-val>TypeError</emu-val> exception.</li><li>Let <var>S</var> be ? <emu-xref aoid="ToString" id="_ref_12457"><a href="abstract-operations.html#sec-tostring" class="e-user-code">ToString</a></emu-xref>(<var>string</var>).</li><li>Let <var>C</var> be ? <emu-xref aoid="SpeciesConstructor" id="_ref_12458"><a href="abstract-operations.html#sec-speciesconstructor" class="e-user-code">SpeciesConstructor</a></emu-xref>(<var>rx</var>, <emu-xref href="#sec-regexp-constructor" id="_ref_12459"><a href="text-processing.html#sec-regexp-constructor">%RegExp%</a></emu-xref>).</li><li>Let <var>flags</var> be ? <emu-xref aoid="ToString" id="_ref_12460"><a href="abstract-operations.html#sec-tostring" class="e-user-code">ToString</a></emu-xref>(? <emu-xref aoid="Get" id="_ref_12461"><a href="abstract-operations.html#sec-get-o-p" class="e-user-code">Get</a></emu-xref>(<var>rx</var>, <emu-val>"flags"</emu-val>)).</li><li>If <var>flags</var> contains <emu-val>"u"</emu-val> or <var>flags</var> contains <emu-val>"v"</emu-val>, let <var>unicodeMatching</var> be <emu-val>true</emu-val>.</li><li>Else, let <var>unicodeMatching</var> be <emu-val>false</emu-val>.</li><li>If <var>flags</var> contains <emu-val>"y"</emu-val>, let <var>newFlags</var> be <var>flags</var>.</li><li>Else, let <var>newFlags</var> be the <emu-xref href="#string-concatenation" id="_ref_12462"><a href="ecmascript-data-types-and-values.html#string-concatenation">string-concatenation</a></emu-xref> of <var>flags</var> and <emu-val>"y"</emu-val>.</li><li>Let <var>splitter</var> be ? <emu-xref aoid="Construct" id="_ref_12463"><a href="abstract-operations.html#sec-construct" class="e-user-code">Construct</a></emu-xref>(<var>C</var>, « <var>rx</var>, <var>newFlags</var> »).</li><li>Let <var>A</var> be ! <emu-xref aoid="ArrayCreate" id="_ref_12464"><a href="ordinary-and-exotic-objects-behaviours.html#sec-arraycreate">ArrayCreate</a></emu-xref>(0).</li><li>Let <var>lengthA</var> be 0.</li><li>If <var>limit</var> is <emu-val>undefined</emu-val>, let <var>lim</var> be 2<sup>32</sup> - 1; else let <var>lim</var> be <emu-xref aoid="ℝ" id="_ref_12465"><a href="notational-conventions.html#%E2%84%9D">ℝ</a></emu-xref>(? <emu-xref aoid="ToUint32" id="_ref_12466"><a href="abstract-operations.html#sec-touint32" class="e-user-code">ToUint32</a></emu-xref>(<var>limit</var>)).</li><li>If <var>lim</var> = 0, return <var>A</var>.</li><li>If <var>S</var> is the empty String, then<ol><li>Let <var>z</var> be ? <emu-xref aoid="RegExpExec" id="_ref_12467"><a href="text-processing.html#sec-regexpexec" class="e-user-code">RegExpExec</a></emu-xref>(<var>splitter</var>, <var>S</var>).</li><li>If <var>z</var> is not <emu-val>null</emu-val>, return <var>A</var>.</li><li>Perform ! <emu-xref aoid="CreateDataPropertyOrThrow" id="_ref_12468"><a href="abstract-operations.html#sec-createdatapropertyorthrow">CreateDataPropertyOrThrow</a></emu-xref>(<var>A</var>, <emu-val>"0"</emu-val>, <var>S</var>).</li><li>Return <var>A</var>.</li></ol></li><li>Let <var>size</var> be the length of <var>S</var>.</li><li>Let <var>p</var> be 0.</li><li>Let <var>q</var> be <var>p</var>.</li><li>Repeat, while <var>q</var> < <var>size</var>,<ol><li>Perform ? <emu-xref aoid="Set" id="_ref_12469"><a href="abstract-operations.html#sec-set-o-p-v-throw" class="e-user-code">Set</a></emu-xref>(<var>splitter</var>, <emu-val>"lastIndex"</emu-val>, <emu-xref aoid="𝔽" id="_ref_12470"><a href="notational-conventions.html#%F0%9D%94%BD">𝔽</a></emu-xref>(<var>q</var>), <emu-val>true</emu-val>).</li><li>Let <var>z</var> be ? <emu-xref aoid="RegExpExec" id="_ref_12471"><a href="text-processing.html#sec-regexpexec" class="e-user-code">RegExpExec</a></emu-xref>(<var>splitter</var>, <var>S</var>).</li><li>If <var>z</var> is <emu-val>null</emu-val>, then<ol><li>Set <var>q</var> to <emu-xref aoid="AdvanceStringIndex" id="_ref_12472"><a href="text-processing.html#sec-advancestringindex">AdvanceStringIndex</a></emu-xref>(<var>S</var>, <var>q</var>, <var>unicodeMatching</var>).</li></ol></li><li>Else,<ol><li>Let <var>e</var> be <emu-xref aoid="ℝ" id="_ref_12473"><a href="notational-conventions.html#%E2%84%9D">ℝ</a></emu-xref>(? <emu-xref aoid="ToLength" id="_ref_12474"><a href="abstract-operations.html#sec-tolength" class="e-user-code">ToLength</a></emu-xref>(? <emu-xref aoid="Get" id="_ref_12475"><a href="abstract-operations.html#sec-get-o-p" class="e-user-code">Get</a></emu-xref>(<var>splitter</var>, <emu-val>"lastIndex"</emu-val>))).</li><li>Set <var>e</var> to <emu-xref aoid="min" id="_ref_12476"><a href="notational-conventions.html#eqn-min">min</a></emu-xref>(<var>e</var>, <var>size</var>).</li><li>If <var>e</var> = <var>p</var>, then<ol><li>Set <var>q</var> to <emu-xref aoid="AdvanceStringIndex" id="_ref_12477"><a href="text-processing.html#sec-advancestringindex">AdvanceStringIndex</a></emu-xref>(<var>S</var>, <var>q</var>, <var>unicodeMatching</var>).</li></ol></li><li>Else,<ol><li>Let <var>T</var> be the <emu-xref href="#substring" id="_ref_12478"><a href="ecmascript-data-types-and-values.html#substring">substring</a></emu-xref> of <var>S</var> from <var>p</var> to <var>q</var>.</li><li>Perform ! <emu-xref aoid="CreateDataPropertyOrThrow" id="_ref_12479"><a href="abstract-operations.html#sec-createdatapropertyorthrow">CreateDataPropertyOrThrow</a></emu-xref>(<var>A</var>, ! <emu-xref aoid="ToString" id="_ref_12480"><a href="abstract-operations.html#sec-tostring">ToString</a></emu-xref>(<emu-xref aoid="𝔽" id="_ref_12481"><a href="notational-conventions.html#%F0%9D%94%BD">𝔽</a></emu-xref>(<var>lengthA</var>)), <var>T</var>).</li><li>Set <var>lengthA</var> to <var>lengthA</var> + 1.</li><li>If <var>lengthA</var> = <var>lim</var>, return <var>A</var>.</li><li>Set <var>p</var> to <var>e</var>.</li><li>Let <var>numberOfCaptures</var> be ? <emu-xref aoid="LengthOfArrayLike" id="_ref_12482"><a href="abstract-operations.html#sec-lengthofarraylike" class="e-user-code">LengthOfArrayLike</a></emu-xref>(<var>z</var>).</li><li>Set <var>numberOfCaptures</var> to <emu-xref aoid="max" id="_ref_12483"><a href="notational-conventions.html#eqn-max">max</a></emu-xref>(<var>numberOfCaptures</var> - 1, 0).</li><li>Let <var>i</var> be 1.</li><li>Repeat, while <var>i</var> ≤ <var>numberOfCaptures</var>,<ol><li>Let <var>nextCapture</var> be ? <emu-xref aoid="Get" id="_ref_12484"><a href="abstract-operations.html#sec-get-o-p" class="e-user-code">Get</a></emu-xref>(<var>z</var>, ! <emu-xref aoid="ToString" id="_ref_12485"><a href="abstract-operations.html#sec-tostring">ToString</a></emu-xref>(<emu-xref aoid="𝔽" id="_ref_12486"><a href="notational-conventions.html#%F0%9D%94%BD">𝔽</a></emu-xref>(<var>i</var>))).</li><li>Perform ! <emu-xref aoid="CreateDataPropertyOrThrow" id="_ref_12487"><a href="abstract-operations.html#sec-createdatapropertyorthrow">CreateDataPropertyOrThrow</a></emu-xref>(<var>A</var>, ! <emu-xref aoid="ToString" id="_ref_12488"><a href="abstract-operations.html#sec-tostring">ToString</a></emu-xref>(<emu-xref aoid="𝔽" id="_ref_12489"><a href="notational-conventions.html#%F0%9D%94%BD">𝔽</a></emu-xref>(<var>lengthA</var>)), <var>nextCapture</var>).</li><li>Set <var>i</var> to <var>i</var> + 1.</li><li>Set <var>lengthA</var> to <var>lengthA</var> + 1.</li><li>If <var>lengthA</var> = <var>lim</var>, return <var>A</var>.</li></ol></li><li>Set <var>q</var> to <var>p</var>.</li></ol></li></ol></li></ol></li><li>Let <var>T</var> be the <emu-xref href="#substring" id="_ref_12490"><a href="ecmascript-data-types-and-values.html#substring">substring</a></emu-xref> of <var>S</var> from <var>p</var> to <var>size</var>.</li><li>Perform ! <emu-xref aoid="CreateDataPropertyOrThrow" id="_ref_12491"><a href="abstract-operations.html#sec-createdatapropertyorthrow">CreateDataPropertyOrThrow</a></emu-xref>(<var>A</var>, ! <emu-xref aoid="ToString" id="_ref_12492"><a href="abstract-operations.html#sec-tostring">ToString</a></emu-xref>(<emu-xref aoid="𝔽" id="_ref_12493"><a href="notational-conventions.html#%F0%9D%94%BD">𝔽</a></emu-xref>(<var>lengthA</var>)), <var>T</var>).</li><li>Return <var>A</var>.</li></ol></emu-alg>
|
||
<p>The value of the <emu-val>"name"</emu-val> property of this method is <emu-val>"[Symbol.split]"</emu-val>.</p>
|
||
<emu-note><span class="note">Note 2</span><div class="note-contents">
|
||
<p>This method ignores the value of the <emu-val>"global"</emu-val> and <emu-val>"sticky"</emu-val> properties of this RegExp object.</p>
|
||
</div></emu-note>
|
||
</emu-clause>
|
||
|
||
<emu-clause id="sec-get-regexp.prototype.sticky" type="built-in function">
|
||
<h1><span class="secnum">22.2.6.15</span> get RegExp.prototype.sticky</h1>
|
||
<p><code>RegExp.prototype.sticky</code> is an <emu-xref href="#sec-object-type" id="_ref_12494"><a href="ecmascript-data-types-and-values.html#sec-object-type">accessor property</a></emu-xref> whose set accessor function is <emu-val>undefined</emu-val>. Its get accessor function performs the following steps when called:</p>
|
||
<emu-alg><ol><li>Let <var>R</var> be the <emu-val>this</emu-val> value.</li><li>Let <var>cu</var> be the code unit 0x0079 (LATIN SMALL LETTER Y).</li><li>Return ? <emu-xref aoid="RegExpHasFlag" id="_ref_12495"><a href="text-processing.html#sec-regexphasflag">RegExpHasFlag</a></emu-xref>(<var>R</var>, <var>cu</var>).</li></ol></emu-alg>
|
||
</emu-clause>
|
||
|
||
<emu-clause id="sec-regexp.prototype.test" type="built-in function">
|
||
<h1><span class="secnum">22.2.6.16</span> RegExp.prototype.test ( <var>S</var> )</h1>
|
||
<p>This method performs the following steps when called:</p>
|
||
<emu-alg><ol><li>Let <var>R</var> be the <emu-val>this</emu-val> value.</li><li>If <var>R</var> <emu-xref href="#sec-object-type" id="_ref_12496"><a href="ecmascript-data-types-and-values.html#sec-object-type">is not an Object</a></emu-xref>, throw a <emu-val>TypeError</emu-val> exception.</li><li>Let <var>string</var> be ? <emu-xref aoid="ToString" id="_ref_12497"><a href="abstract-operations.html#sec-tostring" class="e-user-code">ToString</a></emu-xref>(<var>S</var>).</li><li>Let <var>match</var> be ? <emu-xref aoid="RegExpExec" id="_ref_12498"><a href="text-processing.html#sec-regexpexec" class="e-user-code">RegExpExec</a></emu-xref>(<var>R</var>, <var>string</var>).</li><li>If <var>match</var> is <emu-val>null</emu-val>, return <emu-val>false</emu-val>.</li><li>Return <emu-val>true</emu-val>.</li></ol></emu-alg>
|
||
</emu-clause>
|
||
|
||
<emu-clause id="sec-regexp.prototype.tostring" type="built-in function">
|
||
<h1><span class="secnum">22.2.6.17</span> RegExp.prototype.toString ( )</h1>
|
||
<emu-alg><ol><li>Let <var>R</var> be the <emu-val>this</emu-val> value.</li><li>If <var>R</var> <emu-xref href="#sec-object-type" id="_ref_12499"><a href="ecmascript-data-types-and-values.html#sec-object-type">is not an Object</a></emu-xref>, throw a <emu-val>TypeError</emu-val> exception.</li><li>Let <var>pattern</var> be ? <emu-xref aoid="ToString" id="_ref_12500"><a href="abstract-operations.html#sec-tostring" class="e-user-code">ToString</a></emu-xref>(? <emu-xref aoid="Get" id="_ref_12501"><a href="abstract-operations.html#sec-get-o-p" class="e-user-code">Get</a></emu-xref>(<var>R</var>, <emu-val>"source"</emu-val>)).</li><li>Let <var>flags</var> be ? <emu-xref aoid="ToString" id="_ref_12502"><a href="abstract-operations.html#sec-tostring" class="e-user-code">ToString</a></emu-xref>(? <emu-xref aoid="Get" id="_ref_12503"><a href="abstract-operations.html#sec-get-o-p" class="e-user-code">Get</a></emu-xref>(<var>R</var>, <emu-val>"flags"</emu-val>)).</li><li>Let <var>result</var> be the <emu-xref href="#string-concatenation" id="_ref_12504"><a href="ecmascript-data-types-and-values.html#string-concatenation">string-concatenation</a></emu-xref> of <emu-val>"/"</emu-val>, <var>pattern</var>, <emu-val>"/"</emu-val>, and <var>flags</var>.</li><li>Return <var>result</var>.</li></ol></emu-alg>
|
||
<emu-note><span class="note">Note</span><div class="note-contents">
|
||
<p>The returned String has the form of a <emu-nt id="_ref_24544"><a href="ecmascript-language-lexical-grammar.html#prod-RegularExpressionLiteral">RegularExpressionLiteral</a></emu-nt> that evaluates to another RegExp object with the same behaviour as this object.</p>
|
||
</div></emu-note>
|
||
</emu-clause>
|
||
|
||
<emu-clause id="sec-get-regexp.prototype.unicode" type="built-in function">
|
||
<h1><span class="secnum">22.2.6.18</span> get RegExp.prototype.unicode</h1>
|
||
<p><code>RegExp.prototype.unicode</code> is an <emu-xref href="#sec-object-type" id="_ref_12505"><a href="ecmascript-data-types-and-values.html#sec-object-type">accessor property</a></emu-xref> whose set accessor function is <emu-val>undefined</emu-val>. Its get accessor function performs the following steps when called:</p>
|
||
<emu-alg><ol><li>Let <var>R</var> be the <emu-val>this</emu-val> value.</li><li>Let <var>cu</var> be the code unit 0x0075 (LATIN SMALL LETTER U).</li><li>Return ? <emu-xref aoid="RegExpHasFlag" id="_ref_12506"><a href="text-processing.html#sec-regexphasflag">RegExpHasFlag</a></emu-xref>(<var>R</var>, <var>cu</var>).</li></ol></emu-alg>
|
||
</emu-clause>
|
||
|
||
<emu-clause id="sec-get-regexp.prototype.unicodesets" type="built-in function">
|
||
<h1><span class="secnum">22.2.6.19</span> get RegExp.prototype.unicodeSets</h1>
|
||
<p><code>RegExp.prototype.unicodeSets</code> is an <emu-xref href="#sec-object-type" id="_ref_12507"><a href="ecmascript-data-types-and-values.html#sec-object-type">accessor property</a></emu-xref> whose set accessor function is <emu-val>undefined</emu-val>. Its get accessor function performs the following steps when called:</p>
|
||
<emu-alg><ol><li>Let <var>R</var> be the <emu-val>this</emu-val> value.</li><li>Let <var>cu</var> be the code unit 0x0076 (LATIN SMALL LETTER V).</li><li>Return ? <emu-xref aoid="RegExpHasFlag" id="_ref_12508"><a href="text-processing.html#sec-regexphasflag">RegExpHasFlag</a></emu-xref>(<var>R</var>, <var>cu</var>).</li></ol></emu-alg>
|
||
</emu-clause>
|
||
</emu-clause>
|
||
|
||
<emu-clause id="sec-abstract-operations-for-regexp-matching">
|
||
<h1><span class="secnum">22.2.7</span> Abstract Operations for RegExp Matching</h1>
|
||
|
||
<emu-clause id="sec-regexpexec" type="abstract operation" aoid="RegExpExec">
|
||
<h1><span class="secnum">22.2.7.1</span> RegExpExec ( <var>R</var>, <var>S</var> )</h1>
|
||
<p>The abstract operation RegExpExec takes arguments <var>R</var> (an Object) and <var>S</var> (a String) and returns either a <emu-xref href="#sec-completion-record-specification-type" id="_ref_12509"><a href="ecmascript-data-types-and-values.html#sec-completion-record-specification-type">normal completion containing</a></emu-xref> either an Object or <emu-val>null</emu-val>, or a <emu-xref href="#sec-completion-record-specification-type" id="_ref_12510"><a href="ecmascript-data-types-and-values.html#sec-completion-record-specification-type">throw completion</a></emu-xref>. It performs the following steps when called:</p>
|
||
<emu-alg><ol><li>Let <var>exec</var> be ? <emu-xref aoid="Get" id="_ref_12511"><a href="abstract-operations.html#sec-get-o-p" class="e-user-code">Get</a></emu-xref>(<var>R</var>, <emu-val>"exec"</emu-val>).</li><li>If <emu-xref aoid="IsCallable" id="_ref_12512"><a href="abstract-operations.html#sec-iscallable">IsCallable</a></emu-xref>(<var>exec</var>) is <emu-val>true</emu-val>, then<ol><li>Let <var>result</var> be ? <emu-xref aoid="Call" id="_ref_12513"><a href="abstract-operations.html#sec-call" class="e-user-code">Call</a></emu-xref>(<var>exec</var>, <var>R</var>, « <var>S</var> »).</li><li>If <var>result</var> <emu-xref href="#sec-object-type" id="_ref_12514"><a href="ecmascript-data-types-and-values.html#sec-object-type">is not an Object</a></emu-xref> and <var>result</var> is not <emu-val>null</emu-val>, throw a <emu-val>TypeError</emu-val> exception.</li><li>Return <var>result</var>.</li></ol></li><li>Perform ? <emu-xref aoid="RequireInternalSlot" id="_ref_12515"><a href="ordinary-and-exotic-objects-behaviours.html#sec-requireinternalslot">RequireInternalSlot</a></emu-xref>(<var>R</var>, <var class="field">[[RegExpMatcher]]</var>).</li><li>Return ? <emu-xref aoid="RegExpBuiltinExec" id="_ref_12516"><a href="text-processing.html#sec-regexpbuiltinexec" class="e-user-code">RegExpBuiltinExec</a></emu-xref>(<var>R</var>, <var>S</var>).</li></ol></emu-alg>
|
||
<emu-note><span class="note">Note</span><div class="note-contents">
|
||
<p>If a callable <emu-val>"exec"</emu-val> property is not found this algorithm falls back to attempting to use the built-in RegExp matching algorithm. This provides compatible behaviour for code written for prior editions where most built-in algorithms that use regular expressions did not perform a dynamic property lookup of <emu-val>"exec"</emu-val>.</p>
|
||
</div></emu-note>
|
||
</emu-clause>
|
||
|
||
<emu-clause id="sec-regexpbuiltinexec" type="abstract operation" aoid="RegExpBuiltinExec">
|
||
<h1><span class="secnum">22.2.7.2</span> RegExpBuiltinExec ( <var>R</var>, <var>S</var> )</h1>
|
||
<p>The abstract operation RegExpBuiltinExec takes arguments <var>R</var> (an initialized RegExp instance) and <var>S</var> (a String) and returns either a <emu-xref href="#sec-completion-record-specification-type" id="_ref_12517"><a href="ecmascript-data-types-and-values.html#sec-completion-record-specification-type">normal completion containing</a></emu-xref> either an <emu-xref href="#array-exotic-object" id="_ref_12518"><a href="ordinary-and-exotic-objects-behaviours.html#array-exotic-object">Array exotic object</a></emu-xref> or <emu-val>null</emu-val>, or a <emu-xref href="#sec-completion-record-specification-type" id="_ref_12519"><a href="ecmascript-data-types-and-values.html#sec-completion-record-specification-type">throw completion</a></emu-xref>. It performs the following steps when called:</p>
|
||
<emu-alg><ol><li>Let <var>length</var> be the length of <var>S</var>.</li><li>Let <var>lastIndex</var> be <emu-xref aoid="ℝ" id="_ref_12520"><a href="notational-conventions.html#%E2%84%9D">ℝ</a></emu-xref>(? <emu-xref aoid="ToLength" id="_ref_12521"><a href="abstract-operations.html#sec-tolength" class="e-user-code">ToLength</a></emu-xref>(! <emu-xref aoid="Get" id="_ref_12522"><a href="abstract-operations.html#sec-get-o-p">Get</a></emu-xref>(<var>R</var>, <emu-val>"lastIndex"</emu-val>))).</li><li>Let <var>flags</var> be <var>R</var>.<var class="field">[[OriginalFlags]]</var>.</li><li>If <var>flags</var> contains <emu-val>"g"</emu-val>, let <var>global</var> be <emu-val>true</emu-val>; else let <var>global</var> be <emu-val>false</emu-val>.</li><li>If <var>flags</var> contains <emu-val>"y"</emu-val>, let <var>sticky</var> be <emu-val>true</emu-val>; else let <var>sticky</var> be <emu-val>false</emu-val>.</li><li>If <var>flags</var> contains <emu-val>"d"</emu-val>, let <var>hasIndices</var> be <emu-val>true</emu-val>; else let <var>hasIndices</var> be <emu-val>false</emu-val>.</li><li>If <var>global</var> is <emu-val>false</emu-val> and <var>sticky</var> is <emu-val>false</emu-val>, set <var>lastIndex</var> to 0.</li><li>Let <var>matcher</var> be <var>R</var>.<var class="field">[[RegExpMatcher]]</var>.</li><li>If <var>flags</var> contains <emu-val>"u"</emu-val> or <var>flags</var> contains <emu-val>"v"</emu-val>, let <var>fullUnicode</var> be <emu-val>true</emu-val>; else let <var>fullUnicode</var> be <emu-val>false</emu-val>.</li><li>Let <var>matchSucceeded</var> be <emu-val>false</emu-val>.</li><li>If <var>fullUnicode</var> is <emu-val>true</emu-val>, let <var>input</var> be <emu-xref aoid="StringToCodePoints" id="_ref_12523"><a href="ecmascript-language-source-code.html#sec-stringtocodepoints">StringToCodePoints</a></emu-xref>(<var>S</var>); else let <var>input</var> be a <emu-xref href="#sec-list-and-record-specification-type" id="_ref_12524"><a href="ecmascript-data-types-and-values.html#sec-list-and-record-specification-type">List</a></emu-xref> whose elements are the code units that are the elements of <var>S</var>.</li><li>NOTE: Each element of <var>input</var> is considered to be a character.</li><li>Repeat, while <var>matchSucceeded</var> is <emu-val>false</emu-val>,<ol><li>If <var>lastIndex</var> > <var>length</var>, then<ol><li>If <var>global</var> is <emu-val>true</emu-val> or <var>sticky</var> is <emu-val>true</emu-val>, then<ol><li>Perform ? <emu-xref aoid="Set" id="_ref_12525"><a href="abstract-operations.html#sec-set-o-p-v-throw">Set</a></emu-xref>(<var>R</var>, <emu-val>"lastIndex"</emu-val>, <emu-val>+0</emu-val><sub>𝔽</sub>, <emu-val>true</emu-val>).</li></ol></li><li>Return <emu-val>null</emu-val>.</li></ol></li><li>Let <var>inputIndex</var> be the index into <var>input</var> of the character that was obtained from element <var>lastIndex</var> of <var>S</var>.</li><li>Let <var>r</var> be <var>matcher</var>(<var>input</var>, <var>inputIndex</var>).</li><li>If <var>r</var> is <emu-const>failure</emu-const>, then<ol><li>If <var>sticky</var> is <emu-val>true</emu-val>, then<ol><li>Perform ? <emu-xref aoid="Set" id="_ref_12526"><a href="abstract-operations.html#sec-set-o-p-v-throw">Set</a></emu-xref>(<var>R</var>, <emu-val>"lastIndex"</emu-val>, <emu-val>+0</emu-val><sub>𝔽</sub>, <emu-val>true</emu-val>).</li><li>Return <emu-val>null</emu-val>.</li></ol></li><li>Set <var>lastIndex</var> to <emu-xref aoid="AdvanceStringIndex" id="_ref_12527"><a href="text-processing.html#sec-advancestringindex">AdvanceStringIndex</a></emu-xref>(<var>S</var>, <var>lastIndex</var>, <var>fullUnicode</var>).</li></ol></li><li>Else,<ol><li><emu-xref href="#assert" id="_ref_12528"><a href="notational-conventions.html#assert">Assert</a></emu-xref>: <var>r</var> is a <emu-xref href="#pattern-matchstate" id="_ref_12529"><a href="text-processing.html#pattern-matchstate">MatchState</a></emu-xref>.</li><li>Set <var>matchSucceeded</var> to <emu-val>true</emu-val>.</li></ol></li></ol></li><li>Let <var>e</var> be <var>r</var>.<var class="field">[[EndIndex]]</var>.</li><li>If <var>fullUnicode</var> is <emu-val>true</emu-val>, set <var>e</var> to <emu-xref aoid="GetStringIndex" id="_ref_12530"><a href="text-processing.html#sec-getstringindex">GetStringIndex</a></emu-xref>(<var>S</var>, <var>e</var>).</li><li>If <var>global</var> is <emu-val>true</emu-val> or <var>sticky</var> is <emu-val>true</emu-val>, then<ol><li>Perform ? <emu-xref aoid="Set" id="_ref_12531"><a href="abstract-operations.html#sec-set-o-p-v-throw">Set</a></emu-xref>(<var>R</var>, <emu-val>"lastIndex"</emu-val>, <emu-xref aoid="𝔽" id="_ref_12532"><a href="notational-conventions.html#%F0%9D%94%BD">𝔽</a></emu-xref>(<var>e</var>), <emu-val>true</emu-val>).</li></ol></li><li>Let <var>n</var> be the number of elements in <var>r</var>.<var class="field">[[Captures]]</var>.</li><li><emu-xref href="#assert" id="_ref_12533"><a href="notational-conventions.html#assert">Assert</a></emu-xref>: <var>n</var> = <var>R</var>.<var class="field">[[RegExpRecord]]</var>.<var class="field">[[CapturingGroupsCount]]</var>.</li><li><emu-xref href="#assert" id="_ref_12534"><a href="notational-conventions.html#assert">Assert</a></emu-xref>: <var>n</var> < 2<sup>32</sup> - 1.</li><li>Let <var>A</var> be ! <emu-xref aoid="ArrayCreate" id="_ref_12535"><a href="ordinary-and-exotic-objects-behaviours.html#sec-arraycreate">ArrayCreate</a></emu-xref>(<var>n</var> + 1).</li><li><emu-xref href="#assert" id="_ref_12536"><a href="notational-conventions.html#assert">Assert</a></emu-xref>: The <emu-xref href="#mathematical-value-of" id="_ref_12537"><a href="notational-conventions.html#mathematical-value-of">mathematical value of</a></emu-xref> <var>A</var>'s <emu-val>"length"</emu-val> property is <var>n</var> + 1.</li><li>Perform ! <emu-xref aoid="CreateDataPropertyOrThrow" id="_ref_12538"><a href="abstract-operations.html#sec-createdatapropertyorthrow">CreateDataPropertyOrThrow</a></emu-xref>(<var>A</var>, <emu-val>"index"</emu-val>, <emu-xref aoid="𝔽" id="_ref_12539"><a href="notational-conventions.html#%F0%9D%94%BD">𝔽</a></emu-xref>(<var>lastIndex</var>)).</li><li>Perform ! <emu-xref aoid="CreateDataPropertyOrThrow" id="_ref_12540"><a href="abstract-operations.html#sec-createdatapropertyorthrow">CreateDataPropertyOrThrow</a></emu-xref>(<var>A</var>, <emu-val>"input"</emu-val>, <var>S</var>).</li><li>Let <var>match</var> be the <emu-xref href="#sec-match-records" id="_ref_12541"><a href="text-processing.html#sec-match-records">Match Record</a></emu-xref> { <var class="field">[[StartIndex]]</var>: <var>lastIndex</var>, <var class="field">[[EndIndex]]</var>: <var>e</var> }.</li><li>Let <var>indices</var> be a new empty <emu-xref href="#sec-list-and-record-specification-type" id="_ref_12542"><a href="ecmascript-data-types-and-values.html#sec-list-and-record-specification-type">List</a></emu-xref>.</li><li>Let <var>groupNames</var> be a new empty <emu-xref href="#sec-list-and-record-specification-type" id="_ref_12543"><a href="ecmascript-data-types-and-values.html#sec-list-and-record-specification-type">List</a></emu-xref>.</li><li>Append <var>match</var> to <var>indices</var>.</li><li>Let <var>matchedSubstr</var> be <emu-xref aoid="GetMatchString" id="_ref_12544"><a href="text-processing.html#sec-getmatchstring">GetMatchString</a></emu-xref>(<var>S</var>, <var>match</var>).</li><li>Perform ! <emu-xref aoid="CreateDataPropertyOrThrow" id="_ref_12545"><a href="abstract-operations.html#sec-createdatapropertyorthrow">CreateDataPropertyOrThrow</a></emu-xref>(<var>A</var>, <emu-val>"0"</emu-val>, <var>matchedSubstr</var>).</li><li>If <var>R</var> contains any <emu-nt id="_ref_24545"><a href="text-processing.html#prod-GroupName">GroupName</a></emu-nt>, then<ol><li>Let <var>groups</var> be <emu-xref aoid="OrdinaryObjectCreate" id="_ref_12546"><a href="ordinary-and-exotic-objects-behaviours.html#sec-ordinaryobjectcreate">OrdinaryObjectCreate</a></emu-xref>(<emu-val>null</emu-val>).</li><li>Let <var>hasGroups</var> be <emu-val>true</emu-val>.</li></ol></li><li>Else,<ol><li>Let <var>groups</var> be <emu-val>undefined</emu-val>.</li><li>Let <var>hasGroups</var> be <emu-val>false</emu-val>.</li></ol></li><li>Perform ! <emu-xref aoid="CreateDataPropertyOrThrow" id="_ref_12547"><a href="abstract-operations.html#sec-createdatapropertyorthrow">CreateDataPropertyOrThrow</a></emu-xref>(<var>A</var>, <emu-val>"groups"</emu-val>, <var>groups</var>).</li><li>Let <var>matchedGroupNames</var> be a new empty <emu-xref href="#sec-list-and-record-specification-type" id="_ref_12548"><a href="ecmascript-data-types-and-values.html#sec-list-and-record-specification-type">List</a></emu-xref>.</li><li>For each <emu-xref href="#integer" id="_ref_12549"><a href="notational-conventions.html#integer">integer</a></emu-xref> <var>i</var> such that 1 ≤ <var>i</var> ≤ <var>n</var>, in ascending order, do<ol><li>Let <var>captureI</var> be <var>i</var><sup>th</sup> element of <var>r</var>.<var class="field">[[Captures]]</var>.</li><li>If <var>captureI</var> is <emu-val>undefined</emu-val>, then<ol><li>Let <var>capturedValue</var> be <emu-val>undefined</emu-val>.</li><li>Append <emu-val>undefined</emu-val> to <var>indices</var>.</li></ol></li><li>Else,<ol><li>Let <var>captureStart</var> be <var>captureI</var>.<var class="field">[[StartIndex]]</var>.</li><li>Let <var>captureEnd</var> be <var>captureI</var>.<var class="field">[[EndIndex]]</var>.</li><li>If <var>fullUnicode</var> is <emu-val>true</emu-val>, then<ol><li>Set <var>captureStart</var> to <emu-xref aoid="GetStringIndex" id="_ref_12550"><a href="text-processing.html#sec-getstringindex">GetStringIndex</a></emu-xref>(<var>S</var>, <var>captureStart</var>).</li><li>Set <var>captureEnd</var> to <emu-xref aoid="GetStringIndex" id="_ref_12551"><a href="text-processing.html#sec-getstringindex">GetStringIndex</a></emu-xref>(<var>S</var>, <var>captureEnd</var>).</li></ol></li><li>Let <var>capture</var> be the <emu-xref href="#sec-match-records" id="_ref_12552"><a href="text-processing.html#sec-match-records">Match Record</a></emu-xref> { <var class="field">[[StartIndex]]</var>: <var>captureStart</var>, <var class="field">[[EndIndex]]</var>: <var>captureEnd</var> }.</li><li>Let <var>capturedValue</var> be <emu-xref aoid="GetMatchString" id="_ref_12553"><a href="text-processing.html#sec-getmatchstring">GetMatchString</a></emu-xref>(<var>S</var>, <var>capture</var>).</li><li>Append <var>capture</var> to <var>indices</var>.</li></ol></li><li>Perform ! <emu-xref aoid="CreateDataPropertyOrThrow" id="_ref_12554"><a href="abstract-operations.html#sec-createdatapropertyorthrow">CreateDataPropertyOrThrow</a></emu-xref>(<var>A</var>, ! <emu-xref aoid="ToString" id="_ref_12555"><a href="abstract-operations.html#sec-tostring">ToString</a></emu-xref>(<emu-xref aoid="𝔽" id="_ref_12556"><a href="notational-conventions.html#%F0%9D%94%BD">𝔽</a></emu-xref>(<var>i</var>)), <var>capturedValue</var>).</li><li>If the <var>i</var><sup>th</sup> capture of <var>R</var> was defined with a <emu-nt id="_ref_24546"><a href="text-processing.html#prod-GroupName">GroupName</a></emu-nt>, then<ol><li>Let <var>s</var> be the <emu-xref aoid="CapturingGroupName" id="_ref_12557"><a href="text-processing.html#sec-static-semantics-capturinggroupname">CapturingGroupName</a></emu-xref> of that <emu-nt id="_ref_24547"><a href="text-processing.html#prod-GroupName">GroupName</a></emu-nt>.</li><li>If <var>matchedGroupNames</var> contains <var>s</var>, then<ol><li><emu-xref href="#assert" id="_ref_12558"><a href="notational-conventions.html#assert">Assert</a></emu-xref>: <var>capturedValue</var> is <emu-val>undefined</emu-val>.</li><li>Append <emu-val>undefined</emu-val> to <var>groupNames</var>.</li></ol></li><li>Else,<ol><li>If <var>capturedValue</var> is not <emu-val>undefined</emu-val>, append <var>s</var> to <var>matchedGroupNames</var>.</li><li>NOTE: If there are multiple groups named <var>s</var>, <var>groups</var> may already have an <var>s</var> property at this point. However, because <var>groups</var> is an <emu-xref href="#ordinary-object" id="_ref_12559"><a href="ecmascript-data-types-and-values.html#ordinary-object">ordinary object</a></emu-xref> whose properties are all writable <emu-xref href="#sec-object-type" id="_ref_12560"><a href="ecmascript-data-types-and-values.html#sec-object-type">data properties</a></emu-xref>, the call to <emu-xref aoid="CreateDataPropertyOrThrow" id="_ref_12561"><a href="abstract-operations.html#sec-createdatapropertyorthrow">CreateDataPropertyOrThrow</a></emu-xref> is nevertheless guaranteed to succeed.</li><li>Perform ! <emu-xref aoid="CreateDataPropertyOrThrow" id="_ref_12562"><a href="abstract-operations.html#sec-createdatapropertyorthrow">CreateDataPropertyOrThrow</a></emu-xref>(<var>groups</var>, <var>s</var>, <var>capturedValue</var>).</li><li>Append <var>s</var> to <var>groupNames</var>.</li></ol></li></ol></li><li>Else,<ol><li>Append <emu-val>undefined</emu-val> to <var>groupNames</var>.</li></ol></li></ol></li><li>If <var>hasIndices</var> is <emu-val>true</emu-val>, then<ol><li>Let <var>indicesArray</var> be <emu-xref aoid="MakeMatchIndicesIndexPairArray" id="_ref_12563"><a href="text-processing.html#sec-makematchindicesindexpairarray">MakeMatchIndicesIndexPairArray</a></emu-xref>(<var>S</var>, <var>indices</var>, <var>groupNames</var>, <var>hasGroups</var>).</li><li>Perform ! <emu-xref aoid="CreateDataPropertyOrThrow" id="_ref_12564"><a href="abstract-operations.html#sec-createdatapropertyorthrow">CreateDataPropertyOrThrow</a></emu-xref>(<var>A</var>, <emu-val>"indices"</emu-val>, <var>indicesArray</var>).</li></ol></li><li>Return <var>A</var>.</li></ol></emu-alg>
|
||
</emu-clause>
|
||
|
||
<emu-clause id="sec-advancestringindex" type="abstract operation" aoid="AdvanceStringIndex">
|
||
<h1><span class="secnum">22.2.7.3</span> AdvanceStringIndex ( <var>S</var>, <var>index</var>, <var>unicode</var> )</h1>
|
||
<p>The abstract operation AdvanceStringIndex takes arguments <var>S</var> (a String), <var>index</var> (a non-negative <emu-xref href="#integer" id="_ref_12565"><a href="notational-conventions.html#integer">integer</a></emu-xref>), and <var>unicode</var> (a Boolean) and returns an <emu-xref href="#integer" id="_ref_12566"><a href="notational-conventions.html#integer">integer</a></emu-xref>. It performs the following steps when called:</p>
|
||
<emu-alg><ol><li><emu-xref href="#assert" id="_ref_12567"><a href="notational-conventions.html#assert">Assert</a></emu-xref>: <var>index</var> ≤ 2<sup>53</sup> - 1.</li><li>If <var>unicode</var> is <emu-val>false</emu-val>, return <var>index</var> + 1.</li><li>Let <var>length</var> be the length of <var>S</var>.</li><li>If <var>index</var> + 1 ≥ <var>length</var>, return <var>index</var> + 1.</li><li>Let <var>cp</var> be <emu-xref aoid="CodePointAt" id="_ref_12568"><a href="ecmascript-language-source-code.html#sec-codepointat">CodePointAt</a></emu-xref>(<var>S</var>, <var>index</var>).</li><li>Return <var>index</var> + <var>cp</var>.<var class="field">[[CodeUnitCount]]</var>.</li></ol></emu-alg>
|
||
</emu-clause>
|
||
|
||
<emu-clause id="sec-getstringindex" type="abstract operation" aoid="GetStringIndex">
|
||
<h1><span class="secnum">22.2.7.4</span> GetStringIndex ( <var>S</var>, <var>codePointIndex</var> )</h1>
|
||
<p>The abstract operation GetStringIndex takes arguments <var>S</var> (a String) and <var>codePointIndex</var> (a non-negative <emu-xref href="#integer" id="_ref_12569"><a href="notational-conventions.html#integer">integer</a></emu-xref>) and returns a non-negative <emu-xref href="#integer" id="_ref_12570"><a href="notational-conventions.html#integer">integer</a></emu-xref>. It interprets <var>S</var> as a sequence of UTF-16 encoded code points, as described in <emu-xref href="#sec-ecmascript-language-types-string-type" id="_ref_712"><a href="ecmascript-data-types-and-values.html#sec-ecmascript-language-types-string-type">6.1.4</a></emu-xref>, and returns the code unit index corresponding to code point index <var>codePointIndex</var> when such an index exists. Otherwise, it returns the length of <var>S</var>. It performs the following steps when called:</p>
|
||
<emu-alg><ol><li>If <var>S</var> is the empty String, return 0.</li><li>Let <var>len</var> be the length of <var>S</var>.</li><li>Let <var>codeUnitCount</var> be 0.</li><li>Let <var>codePointCount</var> be 0.</li><li>Repeat, while <var>codeUnitCount</var> < <var>len</var>,<ol><li>If <var>codePointCount</var> = <var>codePointIndex</var>, return <var>codeUnitCount</var>.</li><li>Let <var>cp</var> be <emu-xref aoid="CodePointAt" id="_ref_12571"><a href="ecmascript-language-source-code.html#sec-codepointat">CodePointAt</a></emu-xref>(<var>S</var>, <var>codeUnitCount</var>).</li><li>Set <var>codeUnitCount</var> to <var>codeUnitCount</var> + <var>cp</var>.<var class="field">[[CodeUnitCount]]</var>.</li><li>Set <var>codePointCount</var> to <var>codePointCount</var> + 1.</li></ol></li><li>Return <var>len</var>.</li></ol></emu-alg>
|
||
</emu-clause>
|
||
|
||
<emu-clause id="sec-match-records">
|
||
<h1><span class="secnum">22.2.7.5</span> Match Records</h1>
|
||
<p>A <dfn variants="Match Records" tabindex="-1">Match Record</dfn> is a <emu-xref href="#sec-list-and-record-specification-type" id="_ref_12572"><a href="ecmascript-data-types-and-values.html#sec-list-and-record-specification-type">Record</a></emu-xref> value used to encapsulate the start and end indices of a regular expression match or capture.</p>
|
||
<p>Match Records have the fields listed in <emu-xref href="#table-match-record" id="_ref_713"><a href="text-processing.html#table-match-record">Table 67</a></emu-xref>.</p>
|
||
<emu-table id="table-match-record" caption="Match Record Fields"><figure><figcaption>Table 67: <emu-xref href="#sec-match-records" id="_ref_12573"><a href="text-processing.html#sec-match-records">Match Record</a></emu-xref> Fields</figcaption>
|
||
<table>
|
||
<thead>
|
||
<tr>
|
||
<th>Field Name</th>
|
||
<th>Value</th>
|
||
<th>Meaning</th>
|
||
</tr>
|
||
</thead>
|
||
<tbody><tr>
|
||
<td><var class="field">[[StartIndex]]</var></td>
|
||
<td>a non-negative <emu-xref href="#integer" id="_ref_12574"><a href="notational-conventions.html#integer">integer</a></emu-xref></td>
|
||
<td>The number of code units from the start of a string at which the match begins (inclusive).</td>
|
||
</tr>
|
||
<tr>
|
||
<td><var class="field">[[EndIndex]]</var></td>
|
||
<td>an <emu-xref href="#integer" id="_ref_12575"><a href="notational-conventions.html#integer">integer</a></emu-xref> ≥ <var class="field">[[StartIndex]]</var></td>
|
||
<td>The number of code units from the start of a string at which the match ends (exclusive).</td>
|
||
</tr>
|
||
</tbody></table>
|
||
</figure></emu-table>
|
||
</emu-clause>
|
||
|
||
<emu-clause id="sec-getmatchstring" type="abstract operation" aoid="GetMatchString">
|
||
<h1><span class="secnum">22.2.7.6</span> GetMatchString ( <var>S</var>, <var>match</var> )</h1>
|
||
<p>The abstract operation GetMatchString takes arguments <var>S</var> (a String) and <var>match</var> (a <emu-xref href="#sec-match-records" id="_ref_12576"><a href="text-processing.html#sec-match-records">Match Record</a></emu-xref>) and returns a String. It performs the following steps when called:</p>
|
||
<emu-alg><ol><li><emu-xref href="#assert" id="_ref_12577"><a href="notational-conventions.html#assert">Assert</a></emu-xref>: <var>match</var>.<var class="field">[[StartIndex]]</var> ≤ <var>match</var>.<var class="field">[[EndIndex]]</var> ≤ the length of <var>S</var>.</li><li>Return the <emu-xref href="#substring" id="_ref_12578"><a href="ecmascript-data-types-and-values.html#substring">substring</a></emu-xref> of <var>S</var> from <var>match</var>.<var class="field">[[StartIndex]]</var> to <var>match</var>.<var class="field">[[EndIndex]]</var>.</li></ol></emu-alg>
|
||
</emu-clause>
|
||
|
||
<emu-clause id="sec-getmatchindexpair" type="abstract operation" aoid="GetMatchIndexPair">
|
||
<h1><span class="secnum">22.2.7.7</span> GetMatchIndexPair ( <var>S</var>, <var>match</var> )</h1>
|
||
<p>The abstract operation GetMatchIndexPair takes arguments <var>S</var> (a String) and <var>match</var> (a <emu-xref href="#sec-match-records" id="_ref_12579"><a href="text-processing.html#sec-match-records">Match Record</a></emu-xref>) and returns an Array. It performs the following steps when called:</p>
|
||
<emu-alg><ol><li><emu-xref href="#assert" id="_ref_12580"><a href="notational-conventions.html#assert">Assert</a></emu-xref>: <var>match</var>.<var class="field">[[StartIndex]]</var> ≤ <var>match</var>.<var class="field">[[EndIndex]]</var> ≤ the length of <var>S</var>.</li><li>Return <emu-xref aoid="CreateArrayFromList" id="_ref_12581"><a href="abstract-operations.html#sec-createarrayfromlist">CreateArrayFromList</a></emu-xref>(« <emu-xref aoid="𝔽" id="_ref_12582"><a href="notational-conventions.html#%F0%9D%94%BD">𝔽</a></emu-xref>(<var>match</var>.<var class="field">[[StartIndex]]</var>), <emu-xref aoid="𝔽" id="_ref_12583"><a href="notational-conventions.html#%F0%9D%94%BD">𝔽</a></emu-xref>(<var>match</var>.<var class="field">[[EndIndex]]</var>) »).</li></ol></emu-alg>
|
||
</emu-clause>
|
||
|
||
<emu-clause id="sec-makematchindicesindexpairarray" type="abstract operation" aoid="MakeMatchIndicesIndexPairArray">
|
||
<h1><span class="secnum">22.2.7.8</span> MakeMatchIndicesIndexPairArray ( <var>S</var>, <var>indices</var>, <var>groupNames</var>, <var>hasGroups</var> )</h1>
|
||
<p>The abstract operation MakeMatchIndicesIndexPairArray takes arguments <var>S</var> (a String), <var>indices</var> (a <emu-xref href="#sec-list-and-record-specification-type" id="_ref_12584"><a href="ecmascript-data-types-and-values.html#sec-list-and-record-specification-type">List</a></emu-xref> of either <emu-xref href="#sec-match-records" id="_ref_12585"><a href="text-processing.html#sec-match-records">Match Records</a></emu-xref> or <emu-val>undefined</emu-val>), <var>groupNames</var> (a <emu-xref href="#sec-list-and-record-specification-type" id="_ref_12586"><a href="ecmascript-data-types-and-values.html#sec-list-and-record-specification-type">List</a></emu-xref> of either Strings or <emu-val>undefined</emu-val>), and <var>hasGroups</var> (a Boolean) and returns an Array. It performs the following steps when called:</p>
|
||
<emu-alg><ol><li>Let <var>n</var> be the number of elements in <var>indices</var>.</li><li><emu-xref href="#assert" id="_ref_12587"><a href="notational-conventions.html#assert">Assert</a></emu-xref>: <var>n</var> < 2<sup>32</sup> - 1.</li><li><emu-xref href="#assert" id="_ref_12588"><a href="notational-conventions.html#assert">Assert</a></emu-xref>: <var>groupNames</var> has <var>n</var> - 1 elements.</li><li>NOTE: The <var>groupNames</var> <emu-xref href="#sec-list-and-record-specification-type" id="_ref_12589"><a href="ecmascript-data-types-and-values.html#sec-list-and-record-specification-type">List</a></emu-xref> contains elements aligned with the <var>indices</var> <emu-xref href="#sec-list-and-record-specification-type" id="_ref_12590"><a href="ecmascript-data-types-and-values.html#sec-list-and-record-specification-type">List</a></emu-xref> starting at <var>indices</var>[1].</li><li>Let <var>A</var> be ! <emu-xref aoid="ArrayCreate" id="_ref_12591"><a href="ordinary-and-exotic-objects-behaviours.html#sec-arraycreate">ArrayCreate</a></emu-xref>(<var>n</var>).</li><li>If <var>hasGroups</var> is <emu-val>true</emu-val>, then<ol><li>Let <var>groups</var> be <emu-xref aoid="OrdinaryObjectCreate" id="_ref_12592"><a href="ordinary-and-exotic-objects-behaviours.html#sec-ordinaryobjectcreate">OrdinaryObjectCreate</a></emu-xref>(<emu-val>null</emu-val>).</li></ol></li><li>Else,<ol><li>Let <var>groups</var> be <emu-val>undefined</emu-val>.</li></ol></li><li>Perform ! <emu-xref aoid="CreateDataPropertyOrThrow" id="_ref_12593"><a href="abstract-operations.html#sec-createdatapropertyorthrow">CreateDataPropertyOrThrow</a></emu-xref>(<var>A</var>, <emu-val>"groups"</emu-val>, <var>groups</var>).</li><li>For each <emu-xref href="#integer" id="_ref_12594"><a href="notational-conventions.html#integer">integer</a></emu-xref> <var>i</var> such that 0 ≤ <var>i</var> < <var>n</var>, in ascending order, do<ol><li>Let <var>matchIndices</var> be <var>indices</var>[<var>i</var>].</li><li>If <var>matchIndices</var> is not <emu-val>undefined</emu-val>, then<ol><li>Let <var>matchIndexPair</var> be <emu-xref aoid="GetMatchIndexPair" id="_ref_12595"><a href="text-processing.html#sec-getmatchindexpair">GetMatchIndexPair</a></emu-xref>(<var>S</var>, <var>matchIndices</var>).</li></ol></li><li>Else,<ol><li>Let <var>matchIndexPair</var> be <emu-val>undefined</emu-val>.</li></ol></li><li>Perform ! <emu-xref aoid="CreateDataPropertyOrThrow" id="_ref_12596"><a href="abstract-operations.html#sec-createdatapropertyorthrow">CreateDataPropertyOrThrow</a></emu-xref>(<var>A</var>, ! <emu-xref aoid="ToString" id="_ref_12597"><a href="abstract-operations.html#sec-tostring">ToString</a></emu-xref>(<emu-xref aoid="𝔽" id="_ref_12598"><a href="notational-conventions.html#%F0%9D%94%BD">𝔽</a></emu-xref>(<var>i</var>)), <var>matchIndexPair</var>).</li><li>If <var>i</var> > 0, then<ol><li>Let <var>s</var> be <var>groupNames</var>[<var>i</var> - 1].</li><li>If <var>s</var> is not <emu-val>undefined</emu-val>, then<ol><li><emu-xref href="#assert" id="_ref_12599"><a href="notational-conventions.html#assert">Assert</a></emu-xref>: <var>groups</var> is not <emu-val>undefined</emu-val>.</li><li>NOTE: If there are multiple groups named <var>s</var>, <var>groups</var> may already have an <var>s</var> property at this point. However, because <var>groups</var> is an <emu-xref href="#ordinary-object" id="_ref_12600"><a href="ecmascript-data-types-and-values.html#ordinary-object">ordinary object</a></emu-xref> whose properties are all writable <emu-xref href="#sec-object-type" id="_ref_12601"><a href="ecmascript-data-types-and-values.html#sec-object-type">data properties</a></emu-xref>, the call to <emu-xref aoid="CreateDataPropertyOrThrow" id="_ref_12602"><a href="abstract-operations.html#sec-createdatapropertyorthrow">CreateDataPropertyOrThrow</a></emu-xref> is nevertheless guaranteed to succeed.</li><li>Perform ! <emu-xref aoid="CreateDataPropertyOrThrow" id="_ref_12603"><a href="abstract-operations.html#sec-createdatapropertyorthrow">CreateDataPropertyOrThrow</a></emu-xref>(<var>groups</var>, <var>s</var>, <var>matchIndexPair</var>).</li></ol></li></ol></li></ol></li><li>Return <var>A</var>.</li></ol></emu-alg>
|
||
</emu-clause>
|
||
</emu-clause>
|
||
|
||
<emu-clause id="sec-properties-of-regexp-instances">
|
||
<h1><span class="secnum">22.2.8</span> Properties of RegExp Instances</h1>
|
||
<p>RegExp instances are <emu-xref href="#ordinary-object" id="_ref_12604"><a href="ecmascript-data-types-and-values.html#ordinary-object">ordinary objects</a></emu-xref> that inherit properties from the <emu-xref href="#sec-properties-of-the-regexp-prototype-object" id="_ref_12605"><a href="text-processing.html#sec-properties-of-the-regexp-prototype-object">RegExp prototype object</a></emu-xref>. RegExp instances have internal slots <var class="field">[[OriginalSource]]</var>, <var class="field">[[OriginalFlags]]</var>, <var class="field">[[RegExpRecord]]</var>, and <var class="field">[[RegExpMatcher]]</var>. The value of the <var class="field">[[RegExpMatcher]]</var> internal slot is an <emu-xref href="#sec-abstract-closure" id="_ref_12606"><a href="ecmascript-data-types-and-values.html#sec-abstract-closure">Abstract Closure</a></emu-xref> representation of the <emu-nt id="_ref_24548"><a href="text-processing.html#prod-Pattern">Pattern</a></emu-nt> of the RegExp object.</p>
|
||
<emu-note><span class="note">Note</span><div class="note-contents">
|
||
<p>Prior to ECMAScript 2015, RegExp instances were specified as having the own <emu-xref href="#sec-object-type" id="_ref_12607"><a href="ecmascript-data-types-and-values.html#sec-object-type">data properties</a></emu-xref> <emu-val>"source"</emu-val>, <emu-val>"global"</emu-val>, <emu-val>"ignoreCase"</emu-val>, and <emu-val>"multiline"</emu-val>. Those properties are now specified as <emu-xref href="#sec-object-type" id="_ref_12608"><a href="ecmascript-data-types-and-values.html#sec-object-type">accessor properties</a></emu-xref> of <code>RegExp.prototype</code>.</p>
|
||
</div></emu-note>
|
||
<p>RegExp instances also have the following property:</p>
|
||
|
||
<emu-clause id="sec-lastindex">
|
||
<h1><span class="secnum">22.2.8.1</span> lastIndex</h1>
|
||
<p>The value of the <emu-val>"lastIndex"</emu-val> property specifies the String index at which to start the next match. It is coerced to an <emu-xref href="#integral-number" id="_ref_12609"><a href="notational-conventions.html#integral-number">integral Number</a></emu-xref> when used (see <emu-xref href="#sec-regexpbuiltinexec" id="_ref_714"><a href="text-processing.html#sec-regexpbuiltinexec">22.2.7.2</a></emu-xref>). This property shall have the attributes { <var class="field">[[Writable]]</var>: <emu-val>true</emu-val>, <var class="field">[[Enumerable]]</var>: <emu-val>false</emu-val>, <var class="field">[[Configurable]]</var>: <emu-val>false</emu-val> }.</p>
|
||
</emu-clause>
|
||
</emu-clause>
|
||
|
||
<emu-clause id="sec-regexp-string-iterator-objects">
|
||
<h1><span class="secnum">22.2.9</span> RegExp String Iterator Objects</h1>
|
||
<p>A <dfn variants="RegExp String Iterators,RegExp String Iterator object,RegExp String Iterator objects" tabindex="-1">RegExp String Iterator</dfn> is an object that represents a specific iteration over some specific String instance object, matching against some specific RegExp instance object. There is not a named <emu-xref href="#constructor" id="_ref_12610"><a href="ecmascript-data-types-and-values.html#constructor">constructor</a></emu-xref> for RegExp String Iterator objects. Instead, RegExp String Iterator objects are created by calling certain methods of RegExp instance objects.</p>
|
||
|
||
<emu-clause id="sec-createregexpstringiterator" type="abstract operation" aoid="CreateRegExpStringIterator">
|
||
<h1><span class="secnum">22.2.9.1</span> CreateRegExpStringIterator ( <var>R</var>, <var>S</var>, <var>global</var>, <var>fullUnicode</var> )</h1>
|
||
<p>The abstract operation CreateRegExpStringIterator takes arguments <var>R</var> (an Object), <var>S</var> (a String), <var>global</var> (a Boolean), and <var>fullUnicode</var> (a Boolean) and returns an Object. It performs the following steps when called:</p>
|
||
<emu-alg><ol><li>Let <var>iterator</var> be <emu-xref aoid="OrdinaryObjectCreate" id="_ref_12611"><a href="ordinary-and-exotic-objects-behaviours.html#sec-ordinaryobjectcreate">OrdinaryObjectCreate</a></emu-xref>(<emu-xref href="#sec-%regexpstringiteratorprototype%-object" id="_ref_12612"><a href="text-processing.html#sec-%regexpstringiteratorprototype%-object">%RegExpStringIteratorPrototype%</a></emu-xref>, « <var class="field">[[IteratingRegExp]]</var>, <var class="field">[[IteratedString]]</var>, <var class="field">[[Global]]</var>, <var class="field">[[Unicode]]</var>, <var class="field">[[Done]]</var> »).</li><li>Set <var>iterator</var>.<var class="field">[[IteratingRegExp]]</var> to <var>R</var>.</li><li>Set <var>iterator</var>.<var class="field">[[IteratedString]]</var> to <var>S</var>.</li><li>Set <var>iterator</var>.<var class="field">[[Global]]</var> to <var>global</var>.</li><li>Set <var>iterator</var>.<var class="field">[[Unicode]]</var> to <var>fullUnicode</var>.</li><li>Set <var>iterator</var>.<var class="field">[[Done]]</var> to <emu-val>false</emu-val>.</li><li>Return <var>iterator</var>.</li></ol></emu-alg>
|
||
</emu-clause>
|
||
|
||
<emu-clause id="sec-%regexpstringiteratorprototype%-object">
|
||
<h1><span class="secnum">22.2.9.2</span> The %RegExpStringIteratorPrototype% Object</h1>
|
||
<p>The <dfn tabindex="-1">%RegExpStringIteratorPrototype%</dfn> object:</p>
|
||
<ul>
|
||
<li>has properties that are inherited by all <emu-xref href="#sec-regexp-string-iterator-objects" id="_ref_12613"><a href="text-processing.html#sec-regexp-string-iterator-objects">RegExp String Iterator objects</a></emu-xref>.</li>
|
||
<li>is an <emu-xref href="#ordinary-object" id="_ref_12614"><a href="ecmascript-data-types-and-values.html#ordinary-object">ordinary object</a></emu-xref>.</li>
|
||
<li>has a <var class="field">[[Prototype]]</var> internal slot whose value is <emu-xref href="#sec-%iterator.prototype%-object" id="_ref_12615"><a href="control-abstraction-objects.html#sec-%iterator.prototype%-object">%Iterator.prototype%</a></emu-xref>.</li>
|
||
<li>has the following properties:</li>
|
||
</ul>
|
||
|
||
<emu-clause id="sec-%regexpstringiteratorprototype%.next" type="built-in function">
|
||
<h1><span class="secnum">22.2.9.2.1</span> %RegExpStringIteratorPrototype%.next ( )</h1>
|
||
<emu-alg><ol><li>Let <var>O</var> be the <emu-val>this</emu-val> value.</li><li>If <var>O</var> <emu-xref href="#sec-object-type" id="_ref_12616"><a href="ecmascript-data-types-and-values.html#sec-object-type">is not an Object</a></emu-xref>, throw a <emu-val>TypeError</emu-val> exception.</li><li>If <var>O</var> does not have all of the internal slots of a <emu-xref href="#sec-regexp-string-iterator-objects" id="_ref_12617"><a href="text-processing.html#sec-regexp-string-iterator-objects">RegExp String Iterator</a></emu-xref> Object Instance (see <emu-xref href="#sec-properties-of-regexp-string-iterator-instances" id="_ref_715"><a href="text-processing.html#sec-properties-of-regexp-string-iterator-instances">22.2.9.3</a></emu-xref>), throw a <emu-val>TypeError</emu-val> exception.</li><li>If <var>O</var>.<var class="field">[[Done]]</var> is <emu-val>true</emu-val>, then<ol><li>Return <emu-xref aoid="CreateIteratorResultObject" id="_ref_12618"><a href="abstract-operations.html#sec-createiterresultobject">CreateIteratorResultObject</a></emu-xref>(<emu-val>undefined</emu-val>, <emu-val>true</emu-val>).</li></ol></li><li>Let <var>R</var> be <var>O</var>.<var class="field">[[IteratingRegExp]]</var>.</li><li>Let <var>S</var> be <var>O</var>.<var class="field">[[IteratedString]]</var>.</li><li>Let <var>global</var> be <var>O</var>.<var class="field">[[Global]]</var>.</li><li>Let <var>fullUnicode</var> be <var>O</var>.<var class="field">[[Unicode]]</var>.</li><li>Let <var>match</var> be ? <emu-xref aoid="RegExpExec" id="_ref_12619"><a href="text-processing.html#sec-regexpexec" class="e-user-code">RegExpExec</a></emu-xref>(<var>R</var>, <var>S</var>).</li><li>If <var>match</var> is <emu-val>null</emu-val>, then<ol><li>Set <var>O</var>.<var class="field">[[Done]]</var> to <emu-val>true</emu-val>.</li><li>Return <emu-xref aoid="CreateIteratorResultObject" id="_ref_12620"><a href="abstract-operations.html#sec-createiterresultobject">CreateIteratorResultObject</a></emu-xref>(<emu-val>undefined</emu-val>, <emu-val>true</emu-val>).</li></ol></li><li>If <var>global</var> is <emu-val>false</emu-val>, then<ol><li>Set <var>O</var>.<var class="field">[[Done]]</var> to <emu-val>true</emu-val>.</li><li>Return <emu-xref aoid="CreateIteratorResultObject" id="_ref_12621"><a href="abstract-operations.html#sec-createiterresultobject">CreateIteratorResultObject</a></emu-xref>(<var>match</var>, <emu-val>false</emu-val>).</li></ol></li><li>Let <var>matchStr</var> be ? <emu-xref aoid="ToString" id="_ref_12622"><a href="abstract-operations.html#sec-tostring" class="e-user-code">ToString</a></emu-xref>(? <emu-xref aoid="Get" id="_ref_12623"><a href="abstract-operations.html#sec-get-o-p" class="e-user-code">Get</a></emu-xref>(<var>match</var>, <emu-val>"0"</emu-val>)).</li><li>If <var>matchStr</var> is the empty String, then<ol><li>Let <var>thisIndex</var> be <emu-xref aoid="ℝ" id="_ref_12624"><a href="notational-conventions.html#%E2%84%9D">ℝ</a></emu-xref>(? <emu-xref aoid="ToLength" id="_ref_12625"><a href="abstract-operations.html#sec-tolength" class="e-user-code">ToLength</a></emu-xref>(? <emu-xref aoid="Get" id="_ref_12626"><a href="abstract-operations.html#sec-get-o-p" class="e-user-code">Get</a></emu-xref>(<var>R</var>, <emu-val>"lastIndex"</emu-val>))).</li><li>Let <var>nextIndex</var> be <emu-xref aoid="AdvanceStringIndex" id="_ref_12627"><a href="text-processing.html#sec-advancestringindex">AdvanceStringIndex</a></emu-xref>(<var>S</var>, <var>thisIndex</var>, <var>fullUnicode</var>).</li><li>Perform ? <emu-xref aoid="Set" id="_ref_12628"><a href="abstract-operations.html#sec-set-o-p-v-throw" class="e-user-code">Set</a></emu-xref>(<var>R</var>, <emu-val>"lastIndex"</emu-val>, <emu-xref aoid="𝔽" id="_ref_12629"><a href="notational-conventions.html#%F0%9D%94%BD">𝔽</a></emu-xref>(<var>nextIndex</var>), <emu-val>true</emu-val>).</li></ol></li><li>Return <emu-xref aoid="CreateIteratorResultObject" id="_ref_12630"><a href="abstract-operations.html#sec-createiterresultobject">CreateIteratorResultObject</a></emu-xref>(<var>match</var>, <emu-val>false</emu-val>).</li></ol></emu-alg>
|
||
</emu-clause>
|
||
|
||
<emu-clause oldids="sec-%regexpstringiteratorprototype%-@@tostringtag" id="sec-%regexpstringiteratorprototype%-%symbol.tostringtag%"><span id="sec-%regexpstringiteratorprototype%-@@tostringtag"></span>
|
||
<h1><span class="secnum">22.2.9.2.2</span> %RegExpStringIteratorPrototype% [ %Symbol.toStringTag% ]</h1>
|
||
<p>The initial value of the <emu-xref href="#sec-well-known-symbols" id="_ref_12631"><a href="ecmascript-data-types-and-values.html#sec-well-known-symbols">%Symbol.toStringTag%</a></emu-xref> property is the String value <emu-val>"RegExp String Iterator"</emu-val>.</p>
|
||
<p>This property has the attributes { <var class="field">[[Writable]]</var>: <emu-val>false</emu-val>, <var class="field">[[Enumerable]]</var>: <emu-val>false</emu-val>, <var class="field">[[Configurable]]</var>: <emu-val>true</emu-val> }.</p>
|
||
</emu-clause>
|
||
</emu-clause>
|
||
|
||
<emu-clause id="sec-properties-of-regexp-string-iterator-instances">
|
||
<h1><span class="secnum">22.2.9.3</span> Properties of RegExp String Iterator Instances</h1>
|
||
<p><emu-xref href="#sec-regexp-string-iterator-objects" id="_ref_12632"><a href="text-processing.html#sec-regexp-string-iterator-objects">RegExp String Iterator</a></emu-xref> instances are <emu-xref href="#ordinary-object" id="_ref_12633"><a href="ecmascript-data-types-and-values.html#ordinary-object">ordinary objects</a></emu-xref> that inherit properties from the <emu-xref href="#sec-%regexpstringiteratorprototype%-object" id="_ref_12634"><a href="text-processing.html#sec-%regexpstringiteratorprototype%-object">%RegExpStringIteratorPrototype%</a></emu-xref> intrinsic object. <emu-xref href="#sec-regexp-string-iterator-objects" id="_ref_12635"><a href="text-processing.html#sec-regexp-string-iterator-objects">RegExp String Iterator</a></emu-xref> instances are initially created with the internal slots listed in <emu-xref href="#table-regexp-string-iterator-instance-slots" id="_ref_716"><a href="text-processing.html#table-regexp-string-iterator-instance-slots">Table 68</a></emu-xref>.</p>
|
||
<emu-table id="table-regexp-string-iterator-instance-slots" caption="Internal Slots of RegExp String Iterator Instances"><figure><figcaption>Table 68: Internal Slots of <emu-xref href="#sec-regexp-string-iterator-objects" id="_ref_12636"><a href="text-processing.html#sec-regexp-string-iterator-objects">RegExp String Iterator</a></emu-xref> Instances</figcaption>
|
||
<table>
|
||
<tbody><tr>
|
||
<th>Internal Slot</th>
|
||
<th>Type</th>
|
||
<th>Description</th>
|
||
</tr>
|
||
<tr>
|
||
<td><var class="field">[[IteratingRegExp]]</var></td>
|
||
<td>an Object</td>
|
||
<td>The regular expression used for iteration. <emu-xref aoid="IsRegExp" id="_ref_12637"><a href="abstract-operations.html#sec-isregexp">IsRegExp</a></emu-xref>(<var class="field">[[IteratingRegExp]]</var>) is initially <emu-val>true</emu-val>.</td>
|
||
</tr>
|
||
<tr>
|
||
<td><var class="field">[[IteratedString]]</var></td>
|
||
<td>a String</td>
|
||
<td>The String value being iterated upon.</td>
|
||
</tr>
|
||
<tr>
|
||
<td><var class="field">[[Global]]</var></td>
|
||
<td>a Boolean</td>
|
||
<td>Indicates whether the <var class="field">[[IteratingRegExp]]</var> is global or not.</td>
|
||
</tr>
|
||
<tr>
|
||
<td><var class="field">[[Unicode]]</var></td>
|
||
<td>a Boolean</td>
|
||
<td>Indicates whether the <var class="field">[[IteratingRegExp]]</var> is in Unicode mode or not.</td>
|
||
</tr>
|
||
<tr>
|
||
<td><var class="field">[[Done]]</var></td>
|
||
<td>a Boolean</td>
|
||
<td>Indicates whether the iteration is complete or not.</td>
|
||
</tr>
|
||
</tbody></table>
|
||
</figure></emu-table>
|
||
</emu-clause>
|
||
</emu-clause>
|
||
</emu-clause>
|
||
</emu-clause></div></body></html> |