Regex Pattern Matching Quiz

Sharpen your regular expression skills with this fun and challenging quiz — great for developers, testers, and data pros!

Test Your Regex Knowledge

This quiz will test your understanding of regular expressions with questions ranging from basic to advanced levels.

Quiz Options:

Interactive Regex Guide

Literal characters match themselves exactly:

/hello/ matches "hello"

The dot matches any single character (except newline):

/h.llo/ matches "hello", "hallo", "h3llo"

Character classes match any one of several characters:

/h[ae]llo/ matches "hallo" and "hello"

* matches 0 or more of the preceding item:

/hel*o/ matches "heo", "helo", "hello", "helllo"

+ matches 1 or more of the preceding item:

/hel+o/ matches "helo", "hello", "helllo" but not "heo"

? matches 0 or 1 of the preceding item:

/hel?o/ matches "heo" and "helo" but not "hello"

{n} matches exactly n occurrences:

/hel{2}o/ matches "hello" but not "helo"

^ matches the start of a string:

/^hello/ matches "hello world" but not "world hello"

$ matches the end of a string:

/world$/ matches "hello world" but not "world hello"

\b matches a word boundary:

/\bhello\b/ matches "hello" but not "helloworld"

\d matches any digit (0-9):

/\d+/ matches "123"

\w matches any word character (a-z, A-Z, 0-9, _):

/\w+/ matches "hello_123"

\s matches any whitespace character:

/hello\sworld/ matches "hello world"

Negated character classes match anything not in the class:

/[^0-9]/ matches any non-digit character

Parentheses create capturing groups:

/(\d{3})-(\d{3})/ matches "123-456" capturing "123" and "456"

The pipe | means OR:

/cat|dog/ matches "cat" or "dog"

Non-capturing groups use (?:...):

/(?:https?|ftp):\/\// matches "http://" or "https://" or "ftp://" without capturing

i - Case insensitive matching:

/hello/i matches "Hello", "HELLO", "hElLo"

g - Global matching (find all matches):

/a/g finds all "a" characters in a string

m - Multiline mode (^ and $ match start/end of lines):

/^hello/gm matches "hello" at the start of each line

s - Dot matches newline characters:

/hello.world/s matches "hello\nworld"

What is Regex?

Regular Expressions (Regex) are patterns used to match strings or parts of strings. They are widely used in programming, data validation, parsing, and search operations. Mastering regex helps in writing powerful text-processing tools.

Concepts Covered in This Quiz

Regex Topic Covered
Literal Characters
Character Classes (\d, \w, etc.)
Anchors (^, $)
Quantifiers (*, +, {n})
Groups & Alternation ((a|b))
Special Characters (e.g., .)
Lookaheads/Lookbehinds (optional advanced section)
Escaping characters

Who Should Use This?

  • Programmers & developers
  • QA testers and automation engineers
  • Data scientists
  • Students in computer science

🔎 Regex Pattern Matching Quiz – 📅 Site last updated: August 18, 2025

Added more MCQs across different levels to sharpen your regex skills, perfect for developers, testers, and data professionals.