Skip to content

Commit

Permalink
Only capture first words in repeated pair
Browse files Browse the repository at this point in the history
  • Loading branch information
Rolf Heij committed Aug 28, 2024
1 parent d558e76 commit 8c5760e
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion extensions/src/platform-scripture/src/inventory-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ export const extractRepeatedWords = (
text: string,
target: string | undefined = undefined,
): string[] => {
const repeatedWords = text.match(/\b(\p{L}+)\b \b\1\b/gu) || [];
// Finds repeated words, and captures the first occurrence of the word
const repeatedWords = text.match(/\b(\p{L}+)\b(?= \b\1\b)/gu) || [];

if (target) return repeatedWords?.filter((word) => word === target);

Expand Down

0 comments on commit 8c5760e

Please sign in to comment.