scrimba
Learn Regex
Reuse Patterns Using Capture Groups
Go Pro!Bootcamp

Bootcamp

Study group

Collaborate with peers in your dedicated #study-group channel.

Code reviews

Submit projects for review using the /review command in your #code-reviews channel

Reuse Patterns Using Capture Groups
AboutCommentsNotes
Reuse Patterns Using Capture Groups
Expand for more info
index.js
run
preview
console
let repeatStr = "regex regex";
let repeatRegex = /(\w+)\s\1/;
repeatRegex.test(repeatStr); // Returns true
repeatStr.match(repeatRegex); // Returns ["regex regex", "regex"]

let repeatNum = "42 42 42";
let reRegex = /change/; // Change this line
let result = reRegex.test(repeatNum);
Console
index.html
-5:04