Bird
0
0

How can you use scan to extract all words that do NOT contain the letter 'e' from a string?

hard📝 Application Q9 of 15
Ruby - Regular Expressions
How can you use scan to extract all words that do NOT contain the letter 'e' from a string?
AUse scan with regex /\b\w*e\w*\b/
BUse scan with regex /\b\w+\b/ and filter later
CUse scan with regex /\b[^e\W]+\b/i
DUse scan with regex /\b[^\we]+\b/
Step-by-Step Solution
Solution:
  1. Step 1: Understand regex to exclude 'e'

    The pattern /\b[^e\W]+\b/i matches words without 'e' ignoring case.
  2. Step 2: Explain pattern parts

    Inside brackets [^e\W] means any character except 'e' or non-word chars; + means one or more.
  3. Final Answer:

    Use scan with regex /\b[^e\W]+\b/i -> Option C
  4. Quick Check:

    Exclude letter with negated char class = B [OK]
Quick Trick: Use negated character class [^e] to exclude 'e' [OK]
Common Mistakes:
  • Using regex that matches words containing 'e'
  • Not using word boundaries
  • Incorrect negation syntax

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Ruby Quizzes