Regex basics — literals, test, anchors, and flags
Create simple regexes, test text, use anchors (^ $), and apply common flags (i, g) for small parsing tasks.
Intro to regex
Goal: Recognize and apply tiny regex patterns.
- Create a regex literal like /cat/
- Check with test()
- Use anchors ^ and $
- Add flags: i (ignore case), g (global)

Literal + test()
Create a literal like /cat/ and call test(text) to get true/false.
// Use a regex literal and test() to check presence
const r = /cat/;
console.log("has cat?", r.test("my cat"));
console.log("has cat?", r.test("dog"));

All lessons in this course
- Regex basics — literals, test, anchors, and flags
- Groups, Captures, and Replace
- Validation & small pitfalls