Skip to content

Commit

Permalink
Deploying to gh-pages from @ cd29c60 🚀
Browse files Browse the repository at this point in the history
  • Loading branch information
ljharb committed Oct 12, 2023
1 parent 648dd0a commit 5d216a6
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 @@ -2766,7 +2766,7 @@ <h1><span class="secnum">22.2.5.2</span> RegExp.escape ( <var>S</var> )</h1>
<emu-val>"(){}[]|,.?*+-^$=&lt;&gt;\/#&amp;!%:;@~'"`"</emu-val>.
</p>
<emu-alg><ol><li>Let <var>str</var> be ?&nbsp;<emu-xref aoid="ToString"><a href="https://tc39.es/ecma262/#sec-tostring">ToString</a></emu-xref>(<var>S</var>).</li><li>Let <var>cpList</var> be a <emu-xref href="#sec-list-and-record-specification-type"><a href="https://tc39.es/ecma262/#sec-list-and-record-specification-type">List</a></emu-xref> containing in order the code points as defined in 6.1.4 of <var>str</var>, starting at the first element of <var>str</var>.</li><li>Let <var>toEscape</var> be a <emu-xref href="#pattern-charset"><a href="https://tc39.es/ecma262/#pattern-charset">CharSet</a></emu-xref> containing every character in <emu-xref href="#the ASCII punctuators that need escaping" id="_ref_0"><a href="#the ASCII punctuators that need escaping">the ASCII punctuators that need escaping</a></emu-xref>.</li><li>Let <var>escapedList</var> be a new empty <emu-xref href="#sec-list-and-record-specification-type"><a href="https://tc39.es/ecma262/#sec-list-and-record-specification-type">List</a></emu-xref>.</li><li>For each code point <var>c</var> in <var>cpList</var>, do<ol><li>If <var>escapedList</var> is empty and <var>c</var> is a <emu-nt><a href="https://tc39.es/ecma262/#prod-DecimalDigit">DecimalDigit</a></emu-nt>, then<ol><li>Append code unit U+005C (REVERSE SOLIDUS) to <var>escapedList</var>.</li><li>Append code unit U+0078 (LATIN SMALL LETTER X) to <var>escapedList</var>.</li><li>Append code unit U+0033 (DIGIT THREE) to <var>escapedList</var>.</li></ol></li><li>Else if <var>c</var> is a <emu-xref href="#sec-pattern-notation"><a href="https://tc39.es/ecma262/#sec-pattern-notation">CharSetElement</a></emu-xref> of <var>toEscape</var> or is <emu-nt><a href="https://tc39.es/ecma262/#prod-WhiteSpace">WhiteSpace</a></emu-nt>, then<ol><li>Append code unit U+005C (REVERSE SOLIDUS) to <var>escapedList</var>.</li></ol></li><li>Append the elements of <emu-xref aoid="UTF16EncodeCodePoint"><a href="https://tc39.es/ecma262/#sec-utf16encodecodepoint">UTF16EncodeCodePoint</a></emu-xref>(<var>c</var>) to <var>escapedList</var>.</li></ol></li><li>Return <emu-xref aoid="CodePointsToString"><a href="https://tc39.es/ecma262/#sec-codepointstostring">CodePointsToString</a></emu-xref>(<var>escapedList</var>).</li></ol></emu-alg>
<emu-alg><ol><li>Let <var>str</var> be ?&nbsp;<emu-xref aoid="ToString"><a href="https://tc39.es/ecma262/#sec-tostring">ToString</a></emu-xref>(<var>S</var>).</li><li>Let <var>cpList</var> be a <emu-xref href="#sec-list-and-record-specification-type"><a href="https://tc39.es/ecma262/#sec-list-and-record-specification-type">List</a></emu-xref> containing in order the code points as defined in 6.1.4 of <var>str</var>, starting at the first element of <var>str</var>.</li><li>Let <var>toEscape</var> be a <emu-xref href="#pattern-charset"><a href="https://tc39.es/ecma262/#pattern-charset">CharSet</a></emu-xref> containing every character in <emu-xref href="#the ASCII punctuators that need escaping" id="_ref_0"><a href="#the ASCII punctuators that need escaping">the ASCII punctuators that need escaping</a></emu-xref>.</li><li>Let <var>escapedList</var> be a new empty <emu-xref href="#sec-list-and-record-specification-type"><a href="https://tc39.es/ecma262/#sec-list-and-record-specification-type">List</a></emu-xref>.</li><li>For each code point <var>c</var> in <var>cpList</var>, do<ol><li>If <var>escapedList</var> is empty and <var>c</var> is matched by <emu-nt><a href="https://tc39.es/ecma262/#prod-DecimalDigit">DecimalDigit</a></emu-nt>, then<ol><li>Append code unit U+005C (REVERSE SOLIDUS) to <var>escapedList</var>.</li><li>Append code unit U+0078 (LATIN SMALL LETTER X) to <var>escapedList</var>.</li><li>Append code unit U+0033 (DIGIT THREE) to <var>escapedList</var>.</li></ol></li><li>Else if <var>c</var> is a <emu-xref href="#sec-pattern-notation"><a href="https://tc39.es/ecma262/#sec-pattern-notation">CharSetElement</a></emu-xref> of <var>toEscape</var> or is matched by <emu-nt><a href="https://tc39.es/ecma262/#prod-WhiteSpace">WhiteSpace</a></emu-nt>, then<ol><li>Append code unit U+005C (REVERSE SOLIDUS) to <var>escapedList</var>.</li></ol></li><li>Append the elements of <emu-xref aoid="UTF16EncodeCodePoint"><a href="https://tc39.es/ecma262/#sec-utf16encodecodepoint">UTF16EncodeCodePoint</a></emu-xref>(<var>c</var>) to <var>escapedList</var>.</li></ol></li><li>Return <emu-xref aoid="CodePointsToString"><a href="https://tc39.es/ecma262/#sec-codepointstostring">CodePointsToString</a></emu-xref>(<var>escapedList</var>).</li></ol></emu-alg>
<emu-note><span class="note">Note</span><div class="note-contents">
<p><code>escape</code> takes a string and escapes it so it can be literally represented as a pattern. In contrast <emu-xref aoid="EscapeRegExpPattern"><a href="https://tc39.es/ecma262/#sec-escaperegexppattern">EscapeRegExpPattern</a></emu-xref> (as the name implies) takes a pattern and escapes it so that it can be represented as a string. While the two are related, they do not share the same character escape set or perform similar actions.</p>
Expand Down

0 comments on commit 5d216a6

Please sign in to comment.