1. What does the =~ operator do in Ruby when used with regular expressions? A. Evaluates the regular expression B. Compares two regular expressions C. Matches a string against a regular expression D. Assigns a regular expression to a string Answer & Solution Discuss in Board Save for Later Answer & Solution Answer: Option C No explanation is given for this question Let's Discuss on Board
2. Which method is used to find the first occurrence of a pattern in a string in Ruby? A. String#search B. String#find C. String#find_pattern D. String#match Answer & Solution Discuss in Board Save for Later Answer & Solution Answer: Option D No explanation is given for this question Let's Discuss on Board
3. What does the /\A anchor represent in a regular expression in Ruby? A. Matches one or more occurrences of the previous character B. Matches any character except a newline C. Matches the start of a string D. Matches the end of a string Answer & Solution Discuss in Board Save for Later Answer & Solution Answer: Option C No explanation is given for this question Let's Discuss on Board
4. What is the purpose of the + quantifier in a regular expression in Ruby? A. Matches zero or one occurrence of the preceding character B. Matches zero or more occurrences of the preceding character C. Matches exactly n occurrences of the preceding character D. Matches one or more occurrences of the preceding character Answer & Solution Discuss in Board Save for Later Answer & Solution Answer: Option D No explanation is given for this question Let's Discuss on Board
5. Which modifier is used to perform case-insensitive matching in Ruby regular expressions? A. i B. m C. x D. o Answer & Solution Discuss in Board Save for Later Answer & Solution Answer: Option A No explanation is given for this question Let's Discuss on Board
6. What does the \d character class represent in a regular expression in Ruby? A. Matches any word character B. Matches any whitespace character C. Matches any non-digit character D. Matches any digit character Answer & Solution Discuss in Board Save for Later Answer & Solution Answer: Option D No explanation is given for this question Let's Discuss on Board
7. Which metacharacter is used to specify optional characters in a regular expression in Ruby? A. * B. + C. ? D. . Answer & Solution Discuss in Board Save for Later Answer & Solution Answer: Option C No explanation is given for this question Let's Discuss on Board
8. What does the ^ anchor represent in a regular expression in Ruby? A. Matches the start of a string B. Matches the start of a line C. Matches the end of a string D. Matches the start of a string Answer & Solution Discuss in Board Save for Later Answer & Solution Answer: Option B No explanation is given for this question Let's Discuss on Board
9. Which method is used to replace occurrences of a pattern in a string with a specified string in Ruby? A. String#modify B. String#sub C. String#gsub D. String#replace Answer & Solution Discuss in Board Save for Later Answer & Solution Answer: Option C No explanation is given for this question Let's Discuss on Board
10. What does the \s character class represent in a regular expression in Ruby? A. Matches any non-whitespace character B. Matches any digit character C. Matches any word character D. Matches any whitespace character Answer & Solution Discuss in Board Save for Later Answer & Solution Answer: Option D No explanation is given for this question Let's Discuss on Board