From 59c2e276e474efb96b487a2bd9f8f6ab499e6b8c Mon Sep 17 00:00:00 2001 From: Sumanth Dosapati Date: Sat, 11 Oct 2025 19:14:49 +0530 Subject: [PATCH 1/2] Create script.js --- .../Consecutive duplicate words/script.js | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 Specialized Areas/Regular Expressions/Consecutive duplicate words/script.js diff --git a/Specialized Areas/Regular Expressions/Consecutive duplicate words/script.js b/Specialized Areas/Regular Expressions/Consecutive duplicate words/script.js new file mode 100644 index 0000000000..8bc0c4b975 --- /dev/null +++ b/Specialized Areas/Regular Expressions/Consecutive duplicate words/script.js @@ -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 From 1d00d280f642a6a3a6a0956f2dbb013fab3417df Mon Sep 17 00:00:00 2001 From: Sumanth Dosapati Date: Sat, 11 Oct 2025 19:17:13 +0530 Subject: [PATCH 2/2] Create README.md --- .../Regular Expressions/Consecutive duplicate words/README.md | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 Specialized Areas/Regular Expressions/Consecutive duplicate words/README.md diff --git a/Specialized Areas/Regular Expressions/Consecutive duplicate words/README.md b/Specialized Areas/Regular Expressions/Consecutive duplicate words/README.md new file mode 100644 index 0000000000..a5907a0c3c --- /dev/null +++ b/Specialized Areas/Regular Expressions/Consecutive duplicate words/README.md @@ -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.