Regular expression syntax
Regex backreference
Matches the previously captured text, with matching flags applied; an unmatched group can match empty text.
Formal Syntax & Structure
javascript syntaxjavascript
\1 or \k<name>Working Example
Example Snippetjavascript
console.log(/(ab)-\1/.test("ab-ab"));