0Pricing
NLP Academy · Lesson

Regex in 5 Minutes

Literals, classes, and quantifiers.

Regex in 5 Minutes is a free NLP Academy lesson on CoddyKit — lesson 1 of 4. You can read the complete lesson below for free — then practise it hands-on in the browser with a built-in code editor and a 24/7 AI tutor. It is part of the NLP Academy learning path, one of 4 lessons in the course, and your progress syncs across the web and the CoddyKit app.

A Tiny Language for Patterns

A regular expression is a tiny pattern language for matching text. Instead of one fixed word, you describe the shape of what you want to find.

Python Speaks Regex Too

Python uses the built-in re module for regex. Import it once and you can search, match, and extract patterns from any string.

import re
re.search("cat", "the cat sat")

Literals: Exact Characters

The simplest pattern is a literal. The pattern dog matches the exact letters d, o, g, in that order, wherever they appear in your text.

search Finds the First Match

Use re.search to scan a string and return the first place your pattern appears, or None when nothing matches at all.

m = re.search("sat", "the cat sat")
print(m.group())

Character Classes With Brackets

A character class in square brackets matches any one listed character. The pattern [abc] matches a single a, b, or c each time.

re.findall("[aeiou]", "hello")

Handy Class Shortcuts

Some classes have shortcuts. \d matches any digit, \w matches word characters, and \s matches spaces. They save you a lot of typing. 😊

The Dot Matches Anything

The dot stands for any single character except a newline. So h.t matches hat, hit, and hot, but never the two-letter ht.

Quantifiers Repeat Patterns

A quantifier says how many times the part before it repeats. Add a plus for one or more, a star for zero or more.

re.findall("a+", "aaa banana")

Exact Counts With Braces

Use braces for precise repetition. The pattern \d{3} matches exactly three digits in a row, perfect for area codes or short IDs.

re.findall("\d{3}", "call 911 now")

Anchors Pin the Position

Anchors match a position, not a character. The caret means start of string and the dollar sign means end of string.

findall Returns Every Match

While search finds one match, re.findall returns a list of every match in the text, which is great for counting or extracting many items.

re.findall("\d+", "2 cats, 5 dogs")

Quick Check

You want to match exactly three digits in a row. Which pattern fits?

Recap: Your Regex Toolkit

You met literals, classes, the dot, quantifiers, and anchors. With re.search and re.findall, you can already describe and find real patterns. 🎉

Frequently asked questions

Is the “Regex in 5 Minutes” lesson free?

Yes — the full text of “Regex in 5 Minutes” is free to read here on the web, and the NLP Academy course includes 4 lessons in total. To practise it interactively (a built-in code editor and a 24/7 AI tutor) and unlock the rest of the NLP Academy course, upgrade to CoddyKit PRO.

What will I learn in “Regex in 5 Minutes”?

Literals, classes, and quantifiers. You practise NLP Academy with hands-on code you run directly in the browser, and a 24/7 AI tutor answers your questions as you work through the lesson.

Do I need any experience to start NLP Academy?

No prior experience is required. NLP Academy on CoddyKit is structured for beginners through advanced learners; this is — lesson 1 of 4, so you can start here or from the beginning and move at your own pace.

How long does the “Regex in 5 Minutes” lesson take?

Most CoddyKit lessons take about 5–10 minutes. Each one is bite-sized and interactive, so you make steady progress and pick up exactly where you left off across the web and the app.

Can I write and run code in this NLP Academy lesson?

Yes. Every NLP Academy lesson includes a built-in code editor, so you write and run real code right in your browser and get instant AI feedback — no local setup required.

All lessons in this course

  1. Regex in 5 Minutes
  2. Finding Emails and URLs
  3. Capturing Groups and Replacements
  4. Regex Tokenization Tricks
← Back to NLP Academy