100% Client-Side β’ 0 B Data Leaves Browser
formatting
Duplicate Consecutive Word Regex
Finds accidental repeated words in editorial prose and code comments (e.g., "the the", "in in").
Regular Expression Pattern:
/\b([a-zA-Z]+)\s+\1\b/i
Valid Match Example:
This is the the best tool
Invalid / Non-Match Example:
This is the best tool
Regex Syntax Breakdown & Explanation
- β’\b([a-zA-Z]+) : Matches and captures an entire word at a word boundary
- β’\s+ : One or more whitespace spaces
- β’\1\b : Backreference matches the exact duplicate word
Implementation in Popular Languages
JavaScript / TypeScript
const regex = /\b([a-zA-Z]+)\s+\1\b/i;
const isValid = regex.test("This is the the best tool");
console.log(isValid); // truePython (re)
import re pattern = r"\b([a-zA-Z]+)\s+\1\b" match = re.match(pattern, "This is the the best tool") print(bool(match)) # True
Go (regexp)
package main
import (
"fmt"
"regexp"
)
func main() {
re := regexp.MustCompile(`\b([a-zA-Z]+)\s+\1\b`)
fmt.Println(re.MatchString("This is the the best tool"))
}Frequently Asked Questions
Frequently Asked Questions
Everything you need to know regarding specifications, syntax, and security best practices.
The regular expression pattern is /\b([a-zA-Z]+)\s+\1\b/i. Finds accidental repeated words in editorial prose and code comments (e.g., "the the", "in in").