Bird
0
0

Which of the following is the correct Ruby regex syntax to match any lowercase letter?

easy📝 Syntax Q3 of 15
Ruby - Regular Expressions
Which of the following is the correct Ruby regex syntax to match any lowercase letter?
A"\\a-z"
B"[A-Z]"
C"[a-z]"
D"[0-9]"
Step-by-Step Solution
Solution:
  1. Step 1: Understand character ranges in Ruby regex

    Square brackets [] define a character class. "[a-z]" matches any lowercase letter from a to z.
  2. Step 2: Identify the correct lowercase letter range

    "[a-z]" uses "[a-z]" which is the correct syntax. "[A-Z]" matches uppercase letters, "\\a-z" is invalid, and "[0-9]" matches digits.
  3. Final Answer:

    "[a-z]" matches lowercase letters -> Option C
  4. Quick Check:

    Lowercase letters = "[a-z]" [OK]
Quick Trick: Use [a-z] to match lowercase letters in regex [OK]
Common Mistakes:
  • Using uppercase range [A-Z] instead of lowercase
  • Incorrect escape like \a-z
  • Confusing digits [0-9] with letters

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Ruby Quizzes