Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Consecutive duplicate words

**Overview** - This Regex can be used to find any two consecutive duplicate words. This can be mainly used in client scripts that validates naming conventions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
// Consecutive Duplicate Words Detector
// This regex finds repeated words that appear consecutively, such as "the the" or "and and".
// Useful for grammar or text quality checks.

const duplicateWordsRegex = /\b([A-Za-z]+)\s+\1\b/gi;

function hasDuplicateWords(text) {
return duplicateWordsRegex.test(text);
}

// Example usage:
console.log(hasDuplicateWords("This is the the example.")); // true
console.log(hasDuplicateWords("We need to to check this.")); // true
console.log(hasDuplicateWords("Everything looks good here.")); // false
console.log(hasDuplicateWords("Hello hello world.")); // true (case-insensitive)
console.log(hasDuplicateWords("No repetition found.")); // false
Loading