Skip to content

Commit

Permalink
Fix docs/examples (fixes #344)
Browse files Browse the repository at this point in the history
  • Loading branch information
slevithan committed Jun 5, 2022
1 parent 2dcf16d commit 39e4721
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
6 changes: 3 additions & 3 deletions docs/api/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -438,12 +438,12 @@ <h2 id="exec"><code>XRegExp.exec(<span class="plain">str, regex, [pos], [sticky]

<h3>Example</h3>
<pre class="sh_javascript">// Basic use, with named backreference
let match = XRegExp.exec('U+2620', XRegExp('U\\+(?<hex>[0-9A-F]{4})'));
let match = XRegExp.exec('U+2620', XRegExp('U\\+(?&lt;hex>[0-9A-F]{4})'));
match.groups.hex; // -> '2620'

// With pos and sticky, in a loop
let pos = 2, result = [], match;
while (match = XRegExp.exec('<1><2><3><4>5<6>', /<(\d)>/, pos, 'sticky')) {
let pos = 3, result = [], match;
while (match = XRegExp.exec('&lt;1>&lt;2>&lt;3>&lt;4>5&lt;6>', /&lt;(\d)>/, pos, 'sticky')) {
result.push(match[1]);
pos = match.index + match[0].length;
}
Expand Down
2 changes: 1 addition & 1 deletion src/xregexp.js
Original file line number Diff line number Diff line change
Expand Up @@ -834,7 +834,7 @@ XRegExp.escape = (str) => String(nullThrows(str)).
* match.groups.hex; // -> '2620'
*
* // With pos and sticky, in a loop
* let pos = 2, result = [], match;
* let pos = 3, result = [], match;
* while (match = XRegExp.exec('<1><2><3><4>5<6>', /<(\d)>/, pos, 'sticky')) {
* result.push(match[1]);
* pos = match.index + match[0].length;
Expand Down
2 changes: 1 addition & 1 deletion types/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -595,7 +595,7 @@ declare namespace XRegExp {
* match.groups.hex; // -> '2620'
*
* // With pos and sticky, in a loop
* let pos = 2, result = [], match;
* let pos = 3, result = [], match;
* while (match = XRegExp.exec('<1><2><3><4>5<6>', /<(\d)>/, pos, 'sticky')) {
* result.push(match[1]);
* pos = match.groups.index + match[0].length;
Expand Down

0 comments on commit 39e4721

Please sign in to comment.