Ruby - Regular ExpressionsIdentify the error in this Ruby regex:/[a-z{3,5}]/AMissing escape for curly bracesBCurly braces are inside character class incorrectlyCRange a-z is invalidDNo error, regex is correctCheck Answer
Step-by-Step SolutionSolution:Step 1: Understand quantifiers and character classesCurly braces {3,5} are quantifiers and should be outside character classes []. Inside [] they are treated as literal characters.Step 2: Identify the error in placementPutting {3,5} inside [] is incorrect syntax. It should be /[a-z]{3,5}/ to match 3 to 5 lowercase letters.Final Answer:Curly braces quantifier is incorrectly placed inside character class -> Option BQuick Check:Quantifiers go outside [] in regex [OK]Quick Trick: Quantifiers like {3,5} must be outside character classes [OK]Common Mistakes:Placing quantifiers inside []Not escaping special characters when neededConfusing character class syntax
Master "Regular Expressions" in Ruby9 interactive learning modes - each teaches the same concept differentlyLearnWhyDeepVisualTryChallengeProjectRecallTime
More Ruby Quizzes Advanced Metaprogramming - Module_eval for dynamic behavior - Quiz 5medium Concurrent Programming - Ractor for true parallelism - Quiz 3easy Functional Patterns in Ruby - Why functional patterns complement OOP - Quiz 9hard Functional Patterns in Ruby - Proc composition - Quiz 15hard Gems and Bundler - Why gem management matters - Quiz 13medium Metaprogramming Fundamentals - Open struct for dynamic objects - Quiz 15hard Regular Expressions - Match operator (=~) - Quiz 1easy Ruby Ecosystem and Best Practices - Ruby version management (rbenv, rvm) - Quiz 4medium Testing with RSpec and Minitest - RSpec describe and it blocks - Quiz 5medium Testing with RSpec and Minitest - Minitest basics (assert style) - Quiz 11easy