Skip to content

Commit

Permalink
Change-other-example
Browse files Browse the repository at this point in the history
  • Loading branch information
Himanshuch8055 committed Dec 9, 2023
1 parent 05bb6e4 commit 762430d
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions live-examples/js-examples/regexp/regexp-groups-ranges.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,8 @@ console.log(`Width: ${match[1]} / Height: ${match[2]}.`);
// Expected output: "Width: 1440 / Height: 900."

// Backreferences
const quote = `Single quote "'" and double quote '"'`;
const regexpQuotes = /(['"]).*?\1/g;
for (const match of quote.matchAll(regexpQuotes)) {
console.log(match[0]);
}
// Expected output: '"'"' '"'"'
const findDuplicates = 'foo foo bar';
const regex = /\b(\w+)\s+\1\b/g;
console.log(findDuplicates.match(regex));
// Expected output: Array ["foo", "foo"]

0 comments on commit 762430d

Please sign in to comment.