Ruby - Regular ExpressionsWhat is the purpose of capture groups in Ruby regular expressions?ATo repeat a pattern multiple timesBTo extract specific parts of a matched stringCTo ignore case sensitivity in matchingDTo match only the start of a stringCheck Answer
Step-by-Step SolutionSolution:Step 1: Understand capture groupsCapture groups are parts of a regex enclosed in parentheses that save matched text.Step 2: Identify their purposeThey allow extracting or referencing specific parts of the matched string.Final Answer:To extract specific parts of a matched string -> Option BQuick Check:Capture groups = extract parts [OK]Quick Trick: Parentheses in regex save matched text for reuse [OK]Common Mistakes:Confusing capture groups with non-capturing groupsThinking capture groups repeat patternsAssuming capture groups change case sensitivity
Master "Regular Expressions" in Ruby9 interactive learning modes - each teaches the same concept differentlyLearnWhyDeepVisualTryChallengeProjectRecallTime
More Ruby Quizzes Advanced Metaprogramming - Why hooks enable framework building - Quiz 5medium Advanced Metaprogramming - Module_eval for dynamic behavior - Quiz 7medium Advanced Metaprogramming - DSL building patterns - Quiz 8hard Concurrent Programming - Thread synchronization with Mutex - Quiz 14medium Concurrent Programming - Thread synchronization with Mutex - Quiz 2easy Concurrent Programming - Ractor for true parallelism - Quiz 10hard Metaprogramming Fundamentals - Send for calling methods dynamically - Quiz 3easy Regular Expressions - Gsub with regex - Quiz 12easy Regular Expressions - Gsub with regex - Quiz 10hard Regular Expressions - Why regex is powerful in Ruby - Quiz 9hard