use CGI qw/:standard/; my $stars = qr/\*([^*]*)\*/s; local $_ = 'Hi there *mom* and *dad*'; s/$stars/i($1)/eg; print;