Multiple choice technology programming languages

$string = "good food"; $string =~ s/o*/e/;print $string;

  1. geod food

  2. geed food

  3. geed feed

  4. egood food

Reveal answer Fill a bubble to check yourself
D Correct answer
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.