Regular Expressions (Regex) are cryptic but powerful. They allow you to match complex patterns in text.
Testing Patterns
javascript
const hasNumber = /d+/;
console.log(hasNumber.test("Hello 123")); // true
console.log(hasNumber.test("Hello World")); // falseExtracting Data (Capture Groups)
Modern JS allows "Named Capture Groups", which makes Regex readable.
javascript
const dateStr = "2026-01-30";
const pattern = /(?<year>d{4})-(?<month>d{2})-(?<day>d{2})/;
const match = pattern.exec(dateStr);
console.log(match.groups.year); // "2026"
console.log(match.groups.month); // "01"