Ruby Logo

Quiz: Text Processing

Test your knowledge of regular expressions, string manipulation, parsing & formatting, and time & date handling.

Home Ruby Quiz: Text Processing

Text Processing Quiz

Why Master Ruby Text Processing?

Text processing is fundamental to almost every Ruby application. Whether you're building web applications, APIs, data processing systems, or automation tools, you'll constantly work with strings, dates, and formatted output.

Data Validation

Email formats, phone numbers, user input

Business Logic

Reports, billing, date calculations

Content Management

Text parsing, search, transformation

This comprehensive quiz covers practical scenarios you'll encounter in real-world Ruby development. Test your knowledge of regular expressions, string manipulation, formatting, and time handling.

Quiz Progress

30 Questions | ~20 minutes

Complete all questions to see your results and detailed explanations.

Regular Expressions (8 questions)

1. What does the regex /\b\d{3}-\d{3}-\d{4}\b/ match?

2. What's the difference between /.*?/ and /.*/?

3. How do you access named capture groups in Ruby?

4. What does String#scan return when called with a regex containing capture groups?

5. Which regex modifier makes the pattern case-insensitive?

6. What's the purpose of word boundaries \b in regex?

7. How do you use back-references in regex substitution?

8. What's the main security concern with using Marshal.load that could be addressed with regex validation?

String Manipulation (7 questions)

9. What's the most efficient way to build a large string from many smaller strings?

10. What does "hello".tr('aeiou', 'AEIOU') return?

11. How do you remove all whitespace characters from a string?

12. What's the difference between String#slice and String#[]?

13. How do you check if a string contains another string (case-insensitive)?

14. What does "hello world".squeeze return?

15. How do you pad a string to a specific width with custom characters?

Parsing & Formatting (8 questions)

16. What does sprintf("%05d", 42) return?

17. How do you format a float to show exactly 2 decimal places?

18. What does the %x format specifier do in sprintf?

19. How do you use named arguments with sprintf?

20. What's the difference between printf and sprintf?

21. How do you left-align text within a fixed-width field using sprintf?

22. What does sprintf("%+d", 42) return?

23. How do you format a number with thousands separators using sprintf?

Time & Date (7 questions)

24. What's the difference between Time.now and Time.now.utc?

25. How do you create a specific date using the Date class?

26. What does Time#strftime("%Y-%m-%d") return?

27. How do you check if a year is a leap year using the Date class?

28. What's the best way to parse a date string with unknown format?

29. How do you add 3 months to a Date object?

30. When should you prefer Time over DateTime in modern Ruby?

Quick Navigation

Related Topics

Video Tutorial

Watch and learn quiz: text processing

Pro Tip: After reading through the content above, watch this video to reinforce your understanding and see the concepts in action!