🎙 Free live masterclass · Sun, 29 Nov, 7:00 pm IST · Java Full Stack roadmap Register free →
Skills101
← Quiz: TOC Basics: all 10 questions

Quiz: TOC Basics · Question 5 of 10

Why can't a regular expression match arbitrarily deeply nested brackets?

Why can't a regular expression match arbitrarily deeply nested brackets?

  1. A.Regex engines are too slow
  2. B.Nested brackets form a context-free (not regular) language; finite automata have no memory to count depth
  3. C.Brackets are special characters
  4. D.It can, with enough backslashes
Answer & explanation

Correct answer: Nested brackets form a context-free (not regular) language; finite automata have no memory to count depth

Matching nesting needs a stack — the power of a pushdown automaton.

Can you get the rest right without peeking?

Take the timed Quiz: TOC Basics quiz free. Pass it to earn XP and count towards your certificate.

Start the quiz →