Multiple choice technology programming languages

Which regular expression deletes all tags specified as text enclosed by "<" and ">" from a document stored in a string, but deletes nothing else?

  1. $string =~ s/<*&>//g;
  2. $string =~ s/<\s*>//g;
  3. $string =~ s/<.*?>//g;
  4. $string =~ s/<.*>//g;
Reveal answer Fill a bubble to check yourself
D Correct answer
Explanation

The pattern <.> matches any text enclosed in angle brackets. The * quantifier is greedy by default, matching as much as possible. For nested tags like , <.> matches from the first < to the last >, removing all content between. Option D is the correct greedy regex that deletes all HTML tags.