🎴 Flashcard Mode
Perl Programming
Card1 / 18
Mastered0
Review0
QuestionClick to flip
$string = "good food"; $string =~ s/o*/e/;print $string;
AnswerClick to flip back
A
egood food
💡 Explanation:
The regex s/o*/e/ matches zero or more 'o' characters. At the start of 'good food', it matches zero 'o's (empty string before 'g') and replaces with 'e', producing 'egood food'. This is because * is greedy but matches zero characters when anchored at start. The other options misunderstand how the * quantifier works.