Skip to content
This repository has been archived by the owner on Feb 18, 2025. It is now read-only.

Commit

Permalink
Deploying to gh-pages from @ b714371 🚀
Browse files Browse the repository at this point in the history
  • Loading branch information
ljharb committed Sep 6, 2024
1 parent aab41b9 commit 71c1371
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -3325,7 +3325,7 @@ <h1><span class="secnum">22.2.5.1</span> RegExp.escape ( <var>S</var> )</h1>
<h1><span class="secnum">22.2.5.1.1</span> EncodeForRegExpEscape ( <var>c</var> )</h1>
<p>The abstract operation EncodeForRegExpEscape takes argument <var>c</var> (a code point) and returns a String. It returns a string representing a <emu-nt><a href="https://tc39.es/ecma262/#prod-Pattern">Pattern</a></emu-nt> for matching <var>c</var>. If <var>c</var> is white space or an ASCII punctuator, the returned value is an escape sequence. Otherwise, the returned value is a string representation of <var>c</var> itself. It performs the following steps when called:</p>
<emu-alg><ol><li>If <var>c</var> is matched by <emu-nt><a href="https://tc39.es/ecma262/#prod-SyntaxCharacter">SyntaxCharacter</a></emu-nt> or <var>c</var> is U+002F (SOLIDUS), then<ol><li>Return the <emu-xref href="#string-concatenation"><a href="https://tc39.es/ecma262/#string-concatenation">string-concatenation</a></emu-xref> of 0x005C (REVERSE SOLIDUS) and <emu-xref aoid="UTF16EncodeCodePoint"><a href="https://tc39.es/ecma262/#sec-utf16encodecodepoint">UTF16EncodeCodePoint</a></emu-xref>(<var>c</var>).</li></ol></li><li>Else if <var>c</var> is the code point listed in some cell of the “Code Point” column of <emu-xref href="#table-controlescape-code-point-values"><a href="https://tc39.es/ecma262/#table-controlescape-code-point-values">Table 63</a></emu-xref>, then<ol><li>Return the <emu-xref href="#string-concatenation"><a href="https://tc39.es/ecma262/#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>c</var>.</li></ol></li><li>Let <var>otherPunctuators</var> be the <emu-xref href="#string-concatenation"><a href="https://tc39.es/ecma262/#string-concatenation">string-concatenation</a></emu-xref> of <emu-val>",-=&lt;&gt;#&amp;!%:;@~'`"</emu-val> and the code unit 0x0022 (QUOTATION MARK).</li><li>Let <var>toEscape</var> be <emu-xref aoid="StringToCodePoints"><a href="https://tc39.es/ecma262/#sec-stringtocodepoints">StringToCodePoints</a></emu-xref>(<var>otherPunctuators</var>).</li><li>If <var>toEscape</var> contains <var>c</var>, <var>c</var> is matched by <emu-nt><a href="https://tc39.es/ecma262/#prod-WhiteSpace">WhiteSpace</a></emu-nt> or <emu-nt><a href="https://tc39.es/ecma262/#prod-LineTerminator">LineTerminator</a></emu-nt>, or <var>c</var> has the same numeric value as a <emu-xref href="#leading-surrogate"><a href="https://tc39.es/ecma262/#leading-surrogate">leading surrogate</a></emu-xref> or <emu-xref href="#trailing-surrogate"><a href="https://tc39.es/ecma262/#trailing-surrogate">trailing surrogate</a></emu-xref>, then<ol><li>If the numeric value of <var>c</var> ≤ 0xFF, then<ol><li>Let <var>hex</var> be <emu-xref aoid="Number::toString"><a href="https://tc39.es/ecma262/#sec-numeric-types-number-tostring">Number::toString</a></emu-xref>(<emu-xref aoid="𝔽"><a href="https://tc39.es/ecma262/#𝔽">𝔽</a></emu-xref>(<var>c</var>), 16).</li><li>Return the <emu-xref href="#string-concatenation"><a href="https://tc39.es/ecma262/#string-concatenation">string-concatenation</a></emu-xref> of the code unit 0x005C (REVERSE SOLIDUS), <emu-val>"x"</emu-val>, and <emu-xref aoid="StringPad"><a href="https://tc39.es/ecma262/#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"><a href="https://tc39.es/ecma262/#sec-utf16encodecodepoint">UTF16EncodeCodePoint</a></emu-xref>(<var>c</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"><a href="https://tc39.es/ecma262/#string-concatenation">string-concatenation</a></emu-xref> of <var>escaped</var> and <emu-xref aoid="UnicodeEscape"><a href="https://tc39.es/ecma262/#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"><a href="https://tc39.es/ecma262/#sec-utf16encodecodepoint">UTF16EncodeCodePoint</a></emu-xref>(<var>c</var>).</li></ol></emu-alg>
<emu-alg><ol><li>If <var>c</var> is matched by <emu-nt><a href="https://tc39.es/ecma262/#prod-SyntaxCharacter">SyntaxCharacter</a></emu-nt> or <var>c</var> is U+002F (SOLIDUS), then<ol><li>Return the <emu-xref href="#string-concatenation"><a href="https://tc39.es/ecma262/#string-concatenation">string-concatenation</a></emu-xref> of 0x005C (REVERSE SOLIDUS) and <emu-xref aoid="UTF16EncodeCodePoint"><a href="https://tc39.es/ecma262/#sec-utf16encodecodepoint">UTF16EncodeCodePoint</a></emu-xref>(<var>c</var>).</li></ol></li><li>Else if <var>c</var> is the code point listed in some cell of the “Code Point” column of <emu-xref href="#table-controlescape-code-point-values"><a href="https://tc39.es/ecma262/#table-controlescape-code-point-values">Table 63</a></emu-xref>, then<ol><li>Return the <emu-xref href="#string-concatenation"><a href="https://tc39.es/ecma262/#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>c</var>.</li></ol></li><li>Let <var>otherPunctuators</var> be the <emu-xref href="#string-concatenation"><a href="https://tc39.es/ecma262/#string-concatenation">string-concatenation</a></emu-xref> of <emu-val>",-=&lt;&gt;#&amp;!%:;@~'`"</emu-val> and the code unit 0x0022 (QUOTATION MARK).</li><li>Let <var>toEscape</var> be <emu-xref aoid="StringToCodePoints"><a href="https://tc39.es/ecma262/#sec-stringtocodepoints">StringToCodePoints</a></emu-xref>(<var>otherPunctuators</var>).</li><li>If <var>toEscape</var> contains <var>c</var>, <var>c</var> is matched by either <emu-nt><a href="https://tc39.es/ecma262/#prod-WhiteSpace">WhiteSpace</a></emu-nt> or <emu-nt><a href="https://tc39.es/ecma262/#prod-LineTerminator">LineTerminator</a></emu-nt>, or <var>c</var> has the same numeric value as a <emu-xref href="#leading-surrogate"><a href="https://tc39.es/ecma262/#leading-surrogate">leading surrogate</a></emu-xref> or <emu-xref href="#trailing-surrogate"><a href="https://tc39.es/ecma262/#trailing-surrogate">trailing surrogate</a></emu-xref>, then<ol><li>Let <var>cNum</var> be the numeric value of <var>c</var>.</li><li>If <var>cNum</var> ≤ 0xFF, then<ol><li>Let <var>hex</var> be <emu-xref aoid="Number::toString"><a href="https://tc39.es/ecma262/#sec-numeric-types-number-tostring">Number::toString</a></emu-xref>(<emu-xref aoid="𝔽"><a href="https://tc39.es/ecma262/#𝔽">𝔽</a></emu-xref>(<var>cNum</var>), 16).</li><li>Return the <emu-xref href="#string-concatenation"><a href="https://tc39.es/ecma262/#string-concatenation">string-concatenation</a></emu-xref> of the code unit 0x005C (REVERSE SOLIDUS), <emu-val>"x"</emu-val>, and <emu-xref aoid="StringPad"><a href="https://tc39.es/ecma262/#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"><a href="https://tc39.es/ecma262/#sec-utf16encodecodepoint">UTF16EncodeCodePoint</a></emu-xref>(<var>c</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"><a href="https://tc39.es/ecma262/#string-concatenation">string-concatenation</a></emu-xref> of <var>escaped</var> and <emu-xref aoid="UnicodeEscape"><a href="https://tc39.es/ecma262/#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"><a href="https://tc39.es/ecma262/#sec-utf16encodecodepoint">UTF16EncodeCodePoint</a></emu-xref>(<var>c</var>).</li></ol></emu-alg>
</emu-clause>
</emu-clause>
</ins>
Expand Down

0 comments on commit 71c1371

Please sign in to comment.