Skip to content

Regex Patterns Every Developer Should Know

Master Regex Patterns Every Developer Should Know with 120 free flashcards. Study using spaced repetition and focus mode for effective learning in Programming.

🎓 120 cards ⏱️ ~60 min Advanced
Study Full Deck →
Share: 𝕏 Twitter LinkedIn WhatsApp

🎯 What You'll Learn

Preview Questions

12 shown

What does the regex metacharacter <code>.</code> match by default?

Show ▼

A single character of any kind except the newline character (\n). To make it also match newlines, use the s (dotall / single-line) flag, e.g. /foo.bar/s in JavaScript or re.DOTALL in Python.

Which character class matches any single digit in most regex flavors?

Show ▼

[0-9] or the shorthand \d. \d is equivalent to [0-9] in ASCII; with Unicode (u flag in JS, default in Python 3 str) it matches any Unicode decimal digit, e.g. Arabic-Indic digits.

What does the shorthand <code>\w</code> match?

Show ▼

Any word character. In ASCII mode this is [A-Za-z0-9_]; in Unicode mode it also matches letters and digits from other scripts, and the underscore.

What does the shorthand <code>\s</code> match?

Show ▼

Any whitespace character: space, tab (\t), newline (\n), carriage return (\r), form feed (\f), and vertical tab (\v). In Unicode mode it can also match rare whitespace like the non-breaking space U+00A0.

How do you match a literal dot in a regex?

Show ▼

Escape it with a backslash: \.. Inside a character class the dot is literal even without escaping, but \. still works and is the safe habit.

What is the difference between <code>+</code> and <code>*</code> quantifiers?

Show ▼

* matches zero or more occurrences, so the pattern is optional and may match the empty string. + matches one or more, so at least one occurrence is required.

What does the <code>?</code> quantifier mean when applied to a token?

Show ▼

It makes the token optional (zero or one occurrence). For example, colou?r matches both color and colour.

What is the meaning of the lazy quantifier <code>.*?</code>?

Show ▼

It matches as few characters as possible, expanding only as needed to satisfy the rest of the pattern. Useful for extracting content between the first and last delimiter, e.g. <.*?> matches a single tag.

What does the quantifier <code>{3}</code> mean when applied to a token?

Show ▼

Match the preceding token exactly three times. {3,} means three or more, and {3,5} means between three and five times inclusive.

How do greedy quantifiers behave by default?

Show ▼

They consume as many characters as possible while still allowing the overall pattern to succeed. They then backtrack if the remainder of the pattern fails.

What does the anchor <code>^</code> match?

Show ▼

The position at the start of the string. Inside a character class ([^abc]) it negates the class. With the m (multiline) flag ^ also matches after each newline.

What does the anchor <code>$</code> match?

Show ▼

The position at the end of the string. With the m flag it also matches before each newline. In JavaScript, without the m flag, $ still matches just before a final newline in some engines.

🎓 Start studying Regex Patterns Every Developer Should Know

🎮 Study Modes Available

🔄

Flashcards

Flip to reveal

🧠

Focus Mode

Spaced repetition

Multiple Choice

Test your knowledge

⌨️

Type Answer

Active recall

📚

Learn Mode

Multi-round mastery

🎯

Match Game

Memory challenge

Related Topics in Programming

📖 Learning Resources