Skip to content

Commit

Permalink
Deploying to gh-pages from @ 263eb02 🚀
Browse files Browse the repository at this point in the history
  • Loading branch information
ljharb committed Mar 27, 2024
1 parent 2ee33c5 commit e8a1208
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 @@ -3241,7 +3241,7 @@ <h1><span class="secnum">22.2.5.2</span> RegExp.escape ( <var>S</var> )</h1>
<emu-alg><ol><li>If <var>S</var> <emu-xref href="#sec-ecmascript-language-types-string-type"><a href="https://tc39.es/ecma262/#sec-ecmascript-language-types-string-type">is not a String</a></emu-xref>, throw a TypeError exception.</li><li>Let <var>cpList</var> be <emu-xref aoid="StringToCodePoints"><a href="https://tc39.es/ecma262/#sec-stringtocodepoints">StringToCodePoints</a></emu-xref>(<var>S</var>).</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 the code point U+005C (REVERSE SOLIDUS) to <var>escapedList</var>.</li><li>Append the code point U+0078 (LATIN SMALL LETTER X) to <var>escapedList</var>.</li><li>Append the code point U+0033 (DIGIT THREE) to <var>escapedList</var>.</li><li>Append <var>c</var> to <var>escapedList</var>.</li></ol></li><li>Else,<ol><li>Append the code points in <emu-xref aoid="EncodeForRegExpEscape" id="_ref_0"><a href="#sec-encode">EncodeForRegExpEscape</a></emu-xref>(<var>c</var>) to <var>escapedList</var>.</li></ol></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>
<p>Despite having similar names, <emu-xref aoid="EscapeRegExpPattern"><a href="https://tc39.es/ecma262/#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>
Expand Down

0 comments on commit e8a1208

Please sign in to comment.