Skip to content

Commit 6700c3e

Browse files
committed
Update matchAll
1 parent 16ba6c7 commit 6700c3e

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

docs/engineering/javascript/snippets/match-all.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,10 @@ const getUniqueMatches = (str, regex) => {
1515
const array = [...str.matchAll(regex)]
1616
const finalSet = new Set()
1717
array.forEach(it => finalSet.add(it[1]))
18-
console.log([...finalSet].join('\n'))
18+
const matchesAsArray = [...finalSet]
19+
console.log(matchesAsArray.join('\n'))
20+
console.log(`Found ${finalSet.size} matches`)
21+
return matchesAsArray
1922
}
2023

2124
getUniqueMatches(str, /etc(\/[a-z\-]+\/[a-z\-]+\/[a-z\-]+\/)/g)

0 commit comments

Comments
 (0)