Multiple choice technology programming languages

What will be the value of $str after execution of the following code? my $str = '112133'; $str =~ s/(.)\1/$1/g;

  1. 112133

  2. 1233

  3. 1213

  4. 12133

Reveal answer Fill a bubble to check yourself
C Correct answer
Explanation

The regex /(.)\1/ matches a character followed by itself. Substituting with $1 replaces each pair with a single character. '11'→'1', '21'→'2', '33'→'3', yielding '1213'. The final '3' remains unmatched.